Re: Using for in one-liner

2005-08-17 Thread Reinhold Birkenfeld
BranoZ wrote: > Paul Watson wrote: >> Using a '$' before the string works in the ksh that is part of FC4. >> However, it does not work on the pdksh that is in FC3 and Cygwin. It >> also does not work on AIX ksh. >> >> $ print $'now' >> $now > > In bash you can also use Ctrl-v followed by special

Re: Using for in one-liner

2005-08-15 Thread BranoZ
Paul Watson wrote: > Using a '$' before the string works in the ksh that is part of FC4. > However, it does not work on the pdksh that is in FC3 and Cygwin. It > also does not work on AIX ksh. > > $ print $'now' > $now In bash you can also use Ctrl-v followed by special character. (I used to rese

Re: Using for in one-liner

2005-08-15 Thread Paul Watson
BranoZ wrote: > In "man python" > "Here command may contain multiple statements separated by > newlines. Leading whitespace is significant in Python statements!" > > In "man bash" search for \n (/\\n) > Frankly, I know bash for 10 years, but this has surprised me, too. > > BranoZ Using a '$' be

Re: Using for in one-liner

2005-08-15 Thread BranoZ
In "man python" "Here command may contain multiple statements separated by newlines. Leading whitespace is significant in Python statements!" In "man bash" search for \n (/\\n) Frankly, I know bash for 10 years, but this has surprised me, too. BranoZ -- http://mail.python.org/mailman/listinfo/

Re: Using for in one-liner

2005-08-15 Thread Paul Watson
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 "", line 1 >> import sys;for i in range(5): print i, >> ^ >>SyntaxError: invalid syntax > > > This was tricky

Re: Using for in one-liner

2005-08-15 Thread Paul Watson
[EMAIL PROTECTED] wrote: > to me it seems the ',' is superfluous, this works: python -c "import > sys;print ''.join([l for l in sys.stdin.readlines()])" in 2.4.1 - with > the comma it works as well but it looks weird, as if you want to > un-pack a tuple. Without the comma, an additional newline i

Re: Using for in one-liner

2005-08-15 Thread BranoZ
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 "", line 1 > import sys;for i in range(5): print i, > ^ > SyntaxError: invalid syntax This was tricky.. python -c $'import sys;

Re: Using for in one-liner

2005-08-15 Thread [EMAIL PROTECTED]
to me it seems the ',' is superfluous, this works: python -c "import sys;print ''.join([l for l in sys.stdin.readlines()])" in 2.4.1 - with the comma it works as well but it looks weird, as if you want to un-pack a tuple. -- http://mail.python.org/mailman/listinfo/python-list

Using for in one-liner

2005-08-15 Thread Paul Watson
Can a for loop be used in a one-liner? What am I missing? $ python -c "import sys;print ''.join([line for line in sys.stdin.readlines()])," now is the time now is the time $ python -c "import sys;for line in sys.stdin.readlines(): print line," File "", line 1 import sys;for line in sys.