Python Doc Problem Example: os.system

Xah Lee, 2005-09

Today i'm trying to use Python to call shell commands. e.g. in Perl something like

output=qx(ls)

In Python i quickly located the function due to its well-named-ness:

import os
os.system("ls")

However, according to the doc http://www.python.org/doc/2.4/lib/os-process.html the os.system() returns some esoteric unix thing, not the command output. The doc doesn't say how to get the output of the command.

By chance someone told me that in python 2.4 the os.system is supplanted by subprocess.call(), but this isn't mentioned in the doc!

Upon finding the new doc location http://www.python.org/doc/2.4/lib/module-subprocess.html i'm told that this module replaces:

os.system
os.spawn*
os.popen*
popen2.*
commands.*

Interesting. Since i'm not Python expert, i like to look at these. But the doc gives ample gratis links to OpenSource this or that or author know-how exhibition links to remote book i don't really care about, but here there's no link.

Problem summary:

Solution Suggestion:


Related essays:

Page created: 2005-09.
© 2005 by Xah Lee.
Xah Signet