faqts : Computers : Programming : Languages : Python

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

15 of 22 people (68%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

Is there any way to shell out to a program and return whatever is printed to stdout rather than the exit status?

Nov 30th, 2004 10:27
Chris Burkhardt, Joe Bloggs, unknown unknown, Michael Hudson, Loren Poulsen,


import commands
print commands.__doc__
:-)
----------
Use os.popen() - RTFM.  However, note that for Python 1.5.2 and before,
os.popen often doesnt work on Windows - you need my win32 extensions 
for
this, where win32pipe.popen() does the right thing.  os.popen should
reliably work on Windows in Python 2.0 and later.