popen question

Robert Latest boblatest at yahoo.com
Tue Jan 8 10:20:16 CET 2008


Hello,

look at this function:

--------------
def test():
    child = os.popen('./slow')
    for line in child:
        print line
-------------

The program "slow" just writes the numbers 0 through 9 on stdout, one line a 
second, and then quits.

I would have expected the python program to spit out a numbers one by one, 
instead I see nothing for 10 seconds and then the whole output all at once.

How can I get and process the pipe's output at the pace it is generated?

Thanks,

robert



More information about the Python-list mailing list