Why doesn't response pydoc on my Python 2.7?

Steven D'Aprano steve at pearwood.info
Sat Dec 12 22:42:55 EST 2015


On Sun, 13 Dec 2015 01:31 pm, Robert wrote:

> pydoc.help('module1')
> Help on module module1:


You don't need to do all that. help() has been a built-in command for Python
for, oh, probably a decade or more. Technically, it is added to the
built-ins on startup, so if you mess about with the site.py script or
disable it, it won't be available. But by default, help() should always be
available at the interactive prompt.

Enter this at the interactive Python prompt (by default you will see >>> as
the prompt):

help('sys')


and you will see help for the built-in module sys.

The only time you need to import pydoc is if you wish to use it
programmatically. You don't need it just to view help.

Alternative, at your operating system's command prompt (terminal, shell, DOS
prompt, command line, etc), you may be able to call pydoc as if it were a
program. The shell will probably have a dollar sign $ as the prompt. Enter
this:

pydoc sys

and you will see the help for the sys module. But beware that since you are
using the shell, not python, the syntax rules are different. For example:

Inside Python, [] means an empty list, and you can say help([]) to see help
about lists; but in the system shell, [] is a globbing pattern, and the
result you get will be somewhat different (and platform-dependent).

If the command "pydoc" doesn't work at your shell (remember: the shell has
the $ prompt, Python has the >>> prompt) you can try something like this
instead:

python -m pydoc sys


And last but not least, try calling pydoc without any arguments to see some
extra options.



-- 
Steven




More information about the Python-list mailing list