Python Doc Problem Example: os.system
Robert Wierschke
wierob at gmx.de
Mon Sep 5 04:48:49 EDT 2005
Xah Lee schrieb:
> 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 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.
>
The os.popen(...) function will return a file like object, so you can
use a read() - method of these object to get the called programms output.
hope that helps - I' m very new to python
The documentation may be not well for all circumstances but the fine
thing is: the documentation is part of the code itself - inform of the
docstrings - and this is a very good approach. The bad thing is the
person who wrote the docstring was documenting his/her own code and not
code of other programmers.
More information about the Python-list
mailing list