[Tutor] Python 2.2... os.exec catch stdout

ALAN GAULD alan.gauld at btinternet.com
Sat Jun 6 00:28:47 CEST 2009

If vim is just an unfortunate example then it might be possible but I think
we need to know a bit more about what exactly you are trying to do.

> It's actually  a stand alone program; which opens up a $EDITOR; an 
> then prints to stdout the results of some db munging.  ...
> what I'm wanting to grab is the output printed to stdout after execution.  

In that case use one of subprocesses predecessors, either os.popen 
or the command module. Either of these will start a subprocess and 
return stdout as a file like object.

If you need to send input to the process via stdin you can use popen2
and if you also need access to stderr you can use popen3 - you can 
see why they wanted to rationalise this with subprocess!


Alan G.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090605/458a1131/attachment.htm>

More information about the Tutor mailing list