I'm not a Python expert by any means, but you're describing the
classic symptoms of buffering. There is a '-u' command line switch for
python to turn off buffering but that does not affect file iterators. 
See http://www.hmug.org/man/1/python.html for instance.

Tom Eastman <[EMAIL PROTECTED]> writes:

> I'm not new to Python, but I didn't realise that sys.stdin could be called
> as an iterator, very cool!
>
> However, when I use the following idiom:
>
>    for line in sys.stdin:
>        doSomethingWith(line)

Guess what the suggested work-around on the man page was? Use
sys.stdin.readline() in a "while 1:" loop, as you have below:

>
>    while True:
>       line = sys.stdin.readline()
>       if line == '': break
>       doSomethingWith(line)

David

-- 

David Trudgett
http://www.zeta.org.au/~wpower/

Reality is 20% real and 80% made up stuff in your head.
But I'm not sure about the 20%.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to