python doc in command line

Fredrik Lundh fredrik at pythonware.com
Wed Jul 16 19:22:53 EDT 2008


Peng Yu wrote:

> Perl has a command line help perldoc. I'm wondering if python has a
> similar help command.

it's built into the interpreter, and Python tells you how to use it when 
you start Python in interactive mode.

$ python
Python 2.5.1
Type "help", "copyright", "credits" or "license" for more information.

 >>> help
Type help() for interactive help, or help(object) for help about object.

 >>> help()

Welcome to Python 2.5!  This is the online help utility.

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://www.python.org/doc/tut/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, or topics, type "modules",
"keywords", or "topics".  Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given 
word such as "spam", type "modules spam".

help> quit

You are now leaving help and returning to the Python interpreter.
If you want to ask for help on a particular object directly from the
interpreter, you can type "help(object)".  Executing "help('string')"
has the same effect as typing a particular string at the help> prompt.

 >>> help("string")
Help on module string:

NAME
     string - A collection of string operations (most are no
     longer used).

FILE
     string.py

...

 >>> help(len)
Help on built-in function len in module __builtin__:

len(...)
     len(object) -> integer

     Return the number of items of a sequence or mapping.

 >>>

(etc)

</F>




More information about the Python-list mailing list