Aha. The last method does return values without closing the file, but only if I've sent a large number of lines. This behaves the same way (doesn't work):
Code:
for line in file("pipe"):
print line,
I guess open() uses the file() type, so there isn't much difference here.
Is this some kind of pre-buffering problem? This doesn't work, either:
Code:
for line in file("pipe","r",1):
print line,
Where 1 is buffering:
Code:
If the buffering argument is given, 0 means unbuffered, 1 means line
buffered, and larger numbers specify the buffer size.
It also doesn't work if I open both for reading and writing with 1.
Nor does this:
Code:
for line in f.readlines():
print line,
even though this should be equivalent to
Code:
for line in iter(f.readline, ""):
print line,
which does work.