obtain the output of an external program

Alex Martelli aleax at aleax.it
Mon Nov 17 07:05:58 EST 2003


Fernando Rodriguez wrote:

> How can I save the output of an external program, called with os.system()?

You should use os.popen instead of os.system.  It returns a file-like
object which you can read from (by default, e.g. when you call os.popen
with a single argument) and what you read is exactly the external
program's output.


Alex





More information about the Python-list mailing list