Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Python Doc Problem Example: os.system

Reply
Thread Tools

Python Doc Problem Example: os.system

 
 
Xah Lee
Guest
Posts: n/a
 
      09-05-2005
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.

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/mo...ubprocess.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 incompetent doc gives ample gratis links to OpenSource this
or that or author masturbation links to remote book i don't really care
about, but here there's no link.

Problem summary:

* does not focus on the task users need to do. Instead, the doc is
oriented towards tech geeking.

* does not inform the reader at the right place where a new function is
replacing the old.

* does not provide relevant cross-links. (while provding many
irrelevant links because of OpenSource or Tech Geeking fanaticism)

Solution Suggestion:

* Add examples.

* Add cross-links to relevant modules.

* Mention and add link at the right place supplanted functions.

* Orient the doc to tasks and manifest functionalities. Think like
functional programing: input and output specification, and document
them. This will help focus and precision in the doc. Avoid prose-like
descriptions. Avoid drilling on remotely related tech/unix/C esoterica.
e.g. Do not mention as a documentation how they are implemented.
Mention implementation on the side if necessary. This way, the language
becomes focused as a independent tool (e.g. Mathematica, Java, Scheme,
emacs) (which may provide ample capabilities to interface/connect to
other technologies), instead of heavily intermixed and dependent with a
bunch of other things (unix things: Perl, Apache, shells).

-----------------------------
This article is archive at:
http://xahlee.org/UnixResource_dir/w...on_doc_os.html

Xah

http://xahlee.org/

 
Reply With Quote
 
 
 
 
Robert Wierschke
Guest
Posts: n/a
 
      09-05-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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
can pydoc display doc for local funcs? or other doc tools for owncode News123 Python 0 02-06-2010 12:31 AM
.pdf doc to word doc PWB Computer Support 14 09-19-2008 10:41 PM
String[] files = {"a.doc, b.doc"}; VERSUS String[] files = new String[] {"a.doc, b.doc"}; Matt Java 3 09-17-2004 10:28 PM
Converting a org.jdom DOC to org.w3c DOC Praveen Chhangani XML 2 08-07-2003 08:22 AM
Parsing MS Word client doc into server-side doc... John Wallace ASP .Net 0 07-22-2003 06:49 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57