Python Doc Problem: os.system

By Xah Lee. Date:

Today i'm trying to use Python to call shell commands. In Perl, it's 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 a Python expert, i'd like to look at these. But the doc gives ample gratis links to Open Source 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:

For a tutorial on using subprocess.Popen(), see: Python: Make System Call.

See also: Why Open Source Documentation is of Low Quality

Python Documentation Sucks

  1. Python Doc Problem: os.system
  2. Python Doc Problem: os.path.split()
  3. Python Doc Problem: sort()
  4. Python Doc Problem: gzip
  5. Python Documentation Problems
  6. Python Documentation Author Masturbation
  7. How to Improve Python Doc; Notes on Rewriting Python Regex Doc
  8. Why Python's Documentation Sucks
  9. Python Poetry: the __main__ Stanza
  10. perldoc Coming of Age, What Python Can Learn From?
  11. Examples of Quality Documentation in Computing Industry
  12. Python Doc Links Dead
  13. Python Doc Links All Dead
  14. Python = Pretentious Sheet
  15. Optional Function Parameters in Computer Language Docs (the idiocy thereof)

If you have a question, put $5 at patreon and message me.