Popen and reading stdout in windows

Nobody nobody at nowhere.com
Tue Jun 11 05:54:04 EDT 2013


On Tue, 11 Jun 2013 01:50:07 +0000, Joseph L. Casale wrote:

> I am using Popen to run the exe with communicate() and I have sent stdout
> to PIPE without luck. Just not sure what is the proper way to iterate over
> the stdout as it eventually makes its way from the buffer.

The proper way is:

	p = subprocess.Popen(..., stdout=subprocess.PIPE)
	for line in p.stdout:
	    # use 'line'
	p.wait()

If the program uses stdin, matters get more complicated.




More information about the Python-list mailing list