Starting a child process and getting its stdout?

Tom Plunket tomas at fancy.org
Fri Dec 29 04:38:47 EST 2006


Tom Plunket wrote:

> 	while p.poll() == None:
> 		data = p.stdout.readline()
> 		if data:
> 			print data,

If you change that print to something more decorated, like,

   print 'process said:', data,

Then it might be more obvious where/how the print statements are getting
routed.

Keep in mind that readline() will return one line at a time, and that
line will end with a newline, although the last line you get (at EOF)
may not have one.

again, good luck.  Hope this helps,
-tom!

-- 



More information about the Python-list mailing list