'for l in sys.stdin' at interactive prompt (WAS: Re: sys.stdin.readline())
Hallvard B Furuseth
h.b.furuseth at usit.uio.no
Tue Aug 31 18:47:55 EDT 2004
Steven Bethard wrote:
>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:
> (...)
Whoops - you just found a mysterious bug in a program I'm writing.
Thanks:-)
> 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?
Can't see any in the manual, now that I've looked more closely.
Info node "(python-lib)File Objects" says file.next() uses a read-
ahead buffer. It doesn't say one can disable that.
--
Hallvard
More information about the Python-list
mailing list