Does fileinput.input() read STDIN all at once?
Adam Funk
a24061 at ducksburg.com
Tue Dec 18 08:55:53 EST 2007
I'm using this sort of standard thing:
for line in fileinput.input():
do_stuff(line)
and wondering whether it reads until it hits an EOF and then passes
lines (one at a time) into the variable line. This appears to be the
behaviour when it's reading STDIN interactively (i.e. from the
keyboard).
As a test, I tried this:
for line in fileinput.input():
print '**', line
and found that it would print nothing until I hit Ctl-D, then print
all the lines, then wait for another Ctl-D, and so on (until I pressed
Ctl-D twice in succession to end the loop).
Is it possible to configure this to pass each line of input into line
as it comes?
Thanks,
Adam
More information about the Python-list
mailing list