This will print only the first line of output:
a.py:
import os pipe = os.popen('python test.py') a = pipe.readline() print a
... and it will print all of them
import os pipe = os.popen('python test.py') while True: a = pipe.readline() print a
(I changed test.py to this to make it easier to see what happens:
#!/usr/bin/python x = 0 while True: x = x + 1 print "hello",x
)
david van brink
source share