[docs] Standard Library, Brief Tour, os.system() example, small nit

Robert Terzi rct at r-t.org
Mon Oct 25 16:14:40 CEST 2010


http://docs.python.org/tutorial/stdlib.html

In section 10.1, Operating System Interface, I have a small
nit with the first example for os.system.  First it doesn't
mention what os.system does, Second the example command is
DOS/Windows specific, Third, if run it will change the
current time on your DOS/Windows machine.

I think that example could easily by improved.  My suggestions
for a command that I think will work under Windows, *nix,
and OS X, are either 'mkdir' or 'set' to get a list of
environment variables.



Currently the example text is:

>>> import os
>>> os.system('time 0:02')
0
>>> os.getcwd()      # Return the current working directory
'C:\\Python26'
>>> os.chdir('/server/accesslogs')

My suggestion is:

>>> import os
>>> os.getcwd()      # Return the current working directory
'C:\\Python26'
>>> os.chdir('/server/accesslogs')   # Change current working directory
>>> os.system('mkdir today')   # Run the command mkdir in the system shell
0

Alternate

>>> os.system('set')   # Run the command set in the system shell
<displays a list of environment variables>


Thanks,
--Rob



More information about the docs mailing list