Reading pipes in Python

Rene Pijlman reply.in.the.newsgroup at my.address.is.invalid
Sat Dec 6 15:17:09 EST 2003


Jeroen van der Ham:
>Rene Pijlman:
>>f=open('ff','r')
>>while 1:
>>    li = f.readline()
>>    if not li: break
>>    print li,
>
>This works, but only for a single line.

No, it works for multiple lines as well.

What you probably mean is: it works only for a single writer process. This
is what Linus said about it in 1993: "That's how a fifo is supposed to
work as far as I can tell: when all writers have exited, the reader gets
an EOF and also exits.."
http://groups.google.com/groups?threadm=23vt5j%246ok%40klaava.Helsinki.FI

Try 'cat' instead of a Python script and you'll see exactly the same
behaviour.

-- 
René Pijlman




More information about the Python-list mailing list