'for l in sys.stdin' at interactive prompt (WAS: Re: sys.stdin.readline())
steven.bethard at gmail.com
Tue Aug 31 17:29:51 EDT 2004
Hallvard B Furuseth <h.b.furuseth <at> usit.uio.no> writes:
> Or in newer Pythons, simply `for sL in sys.stdin: print sL'.
This doesn't work for me in the interactive shell:
Python 2.4a2 (#55, Aug 5 2004, 11:42:43) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> for l in sys.stdin:
... print repr(l)
Note that I don't get output until I hit ^Z (this is, obviously, a Windows
box). I tried starting Python with the -u option too, and I still get this
result. Is there any way to make 'for l in sys.stdin' work the way you
suggest it does at an interactive prompt?
More information about the Python-list