Visit www.annedawson.net for more Computer Science Education resources
Last updated: Saturday 28th February 2009, 11:40 PT by AHD
contain more information on the use of the Python programming language.
Python is installed with its own documentation, which can be accessed from:
Start -> Programs -> Python 2.3.4 -> Python Manuals
Help on all aspects of Python can also be found at Python's home page:
In addition to these utilities, the Python interpreter comes with its own help system.
When you start up the Python interpreter, you will see a reminder to type "help" for more information:
Typing help at the Python prompt gives you help on help:
To get help on Python's objects
You can get help on any Python object by typing help(object) at the Python prompt, where object is the name of the object you're interested in.
For example, you may be interested in string objects and can get detailed information by typing help(str) at the Python prompt.
This will generate pages of detailed information on the Python's string class (str). To exit the help pages, type q.
To enter Python's interactive help system, type help() at the Python prompt:
The prompt for Python's interactive help system is:
At the help> prompt you may type in the name of any object to get help on. For example, at the help prompt type str to get help on str.
To exit the help pages, type q.
To exit the help system, type q.
Set up help on Python's keywords
Before you can get help on Python's keywords, you must first download the documentation from www.python.org, then set the environment variable called PYTHONDOCS to the path of the documentation files.
From this site:
http://docs.python.org/download.html, download the HTML ZIP file to your C:\Python23 folder. You must then set the environment variable PYTHONDOCS to the path for your documentation.
For instance, if you download the documentation files to:
then PYTHONDOCS has to be set to that path. The procedure for setting an environment variable will depend on the type of operating system you use. For Windows XP users, you set the variable from
Control Panel -> System
If you have an earlier version of Windows such as Windows 98, you will need to update C:\autoexec.bat to include the line:
Please note: the reason the path is specified as
is because Windows 98 doesn't accept long file names in autoexec.bat files, so a truncated version has to be used.
To check the DOS folder name for a folder such as
go to a DOS shell and type:
cd \python23\docs (then press Enter key)
dir (then press Enter key)
You will then see a directory (folder) listing showing the short name on the left and the long name on the right (see screen shot below). Note that the listing doesn't show the dot between the name PYTHON~1 and the extension 4, but you must supply it as python~1.4 (or PYTHON~1.4) in the autoexec.bat file.
After making saving any changes to the autoexec.bat file you must restart your computer before the changes take effect.
Incidentally, should you want to be able to invoke the Python interpreter from any folder in a DOS shell you should set the PATH environment variable to the folder which contains the Python interpreter file, python.exe. For default installations of Python 2.3.4, the folder is C:\python23
Hence, Windows 98 users should include this line in their autoexec.bat file:
Users of later Windows operating systems should set the PATH environment variable using:
Control Panel -> System
To get help on Python's keywords
Once the PYTHONDOCS environment variable has been set, you will then be able to access help on Python's keywords.
This is the full set of Python's keywords:
and del for is raise
assert elif from lambda return
break else global not try
class except if or while
continue exec import pass yield
def finally in print
For example, to get help on the keyword print
at the Python prompt.
If the PYTHONDOCS environment variable has been correctly set, you will see the following screen:
If you don't get this screen, Python will remind you to set the environment variable.
To exit the help pages, type q, or any other key to go to the next help page on the topic.