Line-by-line processing when stdin is not a tty
invalid at invalid.invalid
Wed Aug 11 17:01:12 CEST 2010
On 2010-08-11, Peter Otten <__peter__ at web.de> wrote:
> Grant Edwards wrote:
>>> If you want to handle stdin a single line at a time from inside of
>>> your program, you can access it using sys.stdin.readline().
>> That doesn't have any effect on stdin buffering.
> "for line in stream"-style file iteration uses an internal buffer that is
> not affected by the -u option; stream.readline() doesnt use this
You're right. Why didn't I know that?
Using "for line in sys.stdin" does it's own buffering.
In my tests using sys.stdin.readline() worked as the OP desired either
with or without -u, either with or without cat. IOW, "cat" isn't
buffering output on my system (or if it is, it's line-buffering).
Grant Edwards grant.b.edwards Yow! I don't know WHY I
at said that ... I think it
gmail.com came from the FILLINGS in
my rear molars ...
More information about the Python-list