BranoZ wrote: > Paul Watson wrote: > >>Can a for loop be used in a one-liner? What am I missing? >> >>$ python -c "import sys;for i in range(5): print i," >> File "<string>", line 1 >> import sys;for i in range(5): print i, >> ^ >>SyntaxError: invalid syntax > > > This was tricky.. > > python -c $'import sys;\nfor i in range(5): print i,' > > Separate statements with <newline> and enclose it in $'string'. > > BranoZ
I did try '\n' a few ways. But, I never thought to add a '$' before the string? What made you think of that? I cannot find any shell documentation about it either. Can you provide a reference? Thanks. -- http://mail.python.org/mailman/listinfo/python-list