A completely silly question
Steven Bethard
steven.bethard at gmail.com
Fri Dec 17 15:14:20 EST 2004
Mike Meyer wrote:
> That doesn't do what he wants, because it doesn't return until you hit
> a newline.
Are you sure that's not just an artifact of how your terminal buffers
data for sys.stdin?
$ cat temp.py
import sys
char = sys.stdin.read(1)
while char:
print char
char = sys.stdin.read(1)
$ cat temp.txt
abc
def
$ python temp.py < temp.txt
a
b
c
d
e
f
Of course if the intent is to have this work with terminal input, then
yes, sys.stdin.read(1) is probably not going to do the right thing...
Steve
More information about the Python-list
mailing list