<!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN">
<link rel=
"STYLESHEET" href=
"lib.css" type='text/css'
/>
<link rel=
"SHORTCUT ICON" href=
"../icons/pyfav.png" type=
"image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index'
/>
<link rel=
"first" href=
"lib.html" title='Python Library Reference'
/>
<link rel='contents' href='contents.html'
title=
"Contents" />
<link rel='index' href='genindex.html' title='Index'
/>
<link rel='last' href='about.html' title='About this document...'
/>
<link rel='help' href='about.html' title='About this document...'
/>
<link rel=
"next" href=
"module-doctest.html" />
<link rel=
"prev" href=
"misc.html" />
<link rel=
"parent" href=
"misc.html" />
<link rel=
"next" href=
"module-doctest.html" />
<meta name='aesop' content='information'
/>
<title>5.1 pydoc -- Documentation generator and online help system
</title>
<div id='top-navigation-panel' xml:id='top-navigation-panel'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<td class='online-navigation'
><a rel=
"prev" title=
"5. Miscellaneous Services"
href=
"misc.html"><img src='../icons/previous.png'
border='
0' height='
32' alt='Previous Page' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"parent" title=
"5. Miscellaneous Services"
href=
"misc.html"><img src='../icons/up.png'
border='
0' height='
32' alt='Up One Level' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"next" title=
"5.2 doctest "
href=
"module-doctest.html"><img src='../icons/next.png'
border='
0' height='
32' alt='Next Page' width='
32'
/></A></td>
<td align=
"center" width=
"100%">Python Library Reference
</td>
<td class='online-navigation'
><a rel=
"contents" title=
"Table of Contents"
href=
"contents.html"><img src='../icons/contents.png'
border='
0' height='
32' alt='Contents' width='
32'
/></A></td>
<td class='online-navigation'
><a href=
"modindex.html" title=
"Module Index"><img src='../icons/modules.png'
border='
0' height='
32' alt='Module Index' width='
32'
/></a></td>
<td class='online-navigation'
><a rel=
"index" title=
"Index"
href=
"genindex.html"><img src='../icons/index.png'
border='
0' height='
32' alt='Index' width='
32'
/></A></td>
<div class='online-navigation'
>
<b class=
"navlabel">Previous:
</b>
<a class=
"sectref" rel=
"prev" href=
"misc.html">5. Miscellaneous Services
</A>
<b class=
"navlabel">Up:
</b>
<a class=
"sectref" rel=
"parent" href=
"misc.html">5. Miscellaneous Services
</A>
<b class=
"navlabel">Next:
</b>
<a class=
"sectref" rel=
"next" href=
"module-doctest.html">5.2 doctest
</A>
<!--End of Navigation Panel-->
<H1><A NAME=
"SECTION007100000000000000000">
5.1 <tt class=
"module">pydoc
</tt> --
Documentation generator and online help system
</A>
<A NAME=
"module-pydoc"></A>
<span class=
"versionnote">New in version
2.1.
</span>
<a id='l2h-
1059' xml:id='l2h-
1059'
></a>
The
<tt class=
"module">pydoc
</tt> module automatically generates documentation from
Python modules. The documentation can be presented as pages of text
on the console, served to a Web browser, or saved to HTML files.
The built-in function
<tt class=
"function">help()
</tt> invokes the online help system
in the interactive interpreter, which uses
<tt class=
"module">pydoc
</tt> to generate
its documentation as text on the console. The same text documentation
can also be viewed from outside the Python interpreter by running
<b class=
"program">pydoc
</b> as a script at the operating system's command prompt.
<div class=
"verbatim"><pre>
at a shell prompt will display documentation on the
<tt class=
"module"><a href=
"module-sys.html">sys
</a></tt>
module, in a style similar to the manual pages shown by the
<span class=
"Unix">Unix
</span>
<b class=
"program">man
</b> command. The argument to
<b class=
"program">pydoc
</b> can be the name
of a function, module, or package, or a dotted reference to a class,
method, or function within a module or module in a package. If the
argument to
<b class=
"program">pydoc
</b> looks like a path (that is, it contains the
path separator for your operating system, such as a slash in
<span class=
"Unix">Unix
</span>),
and refers to an existing Python source file, then documentation is
Specifying a
<b class=
"programopt">-w
</b> flag before the argument will cause HTML
documentation to be written out to a file in the current directory,
instead of displaying text on the console.
Specifying a
<b class=
"programopt">-k
</b> flag before the argument will search the
synopsis lines of all available modules for the keyword given as the
argument, again in a manner similar to the
<span class=
"Unix">Unix
</span> <b class=
"program">man
</b>
command. The synopsis line of a module is the first line of its
You can also use
<b class=
"program">pydoc
</b> to start an HTTP server on the local
machine that will serve documentation to visiting Web browsers.
<b class=
"program">pydoc
</b> <b class=
"programopt">-p
1234</b> will start a HTTP server on port
1234, allowing you to browse the documentation at
<code>http://localhost:
1234/
</code> in your preferred Web browser.
<b class=
"program">pydoc
</b> <b class=
"programopt">-g
</b> will start the server and additionally
bring up a small
<tt class=
"module"><a href=
"module-Tkinter.html">Tkinter
</a></tt>-based graphical interface to help
you search for documentation pages.
When
<b class=
"program">pydoc
</b> generates documentation, it uses the current
environment and path to locate modules. Thus, invoking
<b class=
"program">pydoc
</b> <b class=
"programopt">spam
</b> documents precisely the version of
the module you would get if you started the Python interpreter and
typed
"<tt class="samp
">import spam</tt>".
Module docs for core modules are assumed to reside in
<a class=
"url" href=
"http://www.python.org/doc/current/lib/">http://www.python.org/doc/current/lib/
</a>. This can be overridden by
setting the
<a class=
"envvar" id='l2h-
1060' xml:id='l2h-
1060'
>PYTHONDOCS
</a> environment variable to a different URL or
to a local directory containing the Library Reference Manual pages.
<div class='online-navigation'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<td class='online-navigation'
><a rel=
"prev" title=
"5. Miscellaneous Services"
href=
"misc.html"><img src='../icons/previous.png'
border='
0' height='
32' alt='Previous Page' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"parent" title=
"5. Miscellaneous Services"
href=
"misc.html"><img src='../icons/up.png'
border='
0' height='
32' alt='Up One Level' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"next" title=
"5.2 doctest "
href=
"module-doctest.html"><img src='../icons/next.png'
border='
0' height='
32' alt='Next Page' width='
32'
/></A></td>
<td align=
"center" width=
"100%">Python Library Reference
</td>
<td class='online-navigation'
><a rel=
"contents" title=
"Table of Contents"
href=
"contents.html"><img src='../icons/contents.png'
border='
0' height='
32' alt='Contents' width='
32'
/></A></td>
<td class='online-navigation'
><a href=
"modindex.html" title=
"Module Index"><img src='../icons/modules.png'
border='
0' height='
32' alt='Module Index' width='
32'
/></a></td>
<td class='online-navigation'
><a rel=
"index" title=
"Index"
href=
"genindex.html"><img src='../icons/index.png'
border='
0' height='
32' alt='Index' width='
32'
/></A></td>
<div class='online-navigation'
>
<b class=
"navlabel">Previous:
</b>
<a class=
"sectref" rel=
"prev" href=
"misc.html">5. Miscellaneous Services
</A>
<b class=
"navlabel">Up:
</b>
<a class=
"sectref" rel=
"parent" href=
"misc.html">5. Miscellaneous Services
</A>
<b class=
"navlabel">Next:
</b>
<a class=
"sectref" rel=
"next" href=
"module-doctest.html">5.2 doctest
</A>
<span class=
"release-info">Release
2.4.2, documentation updated on
28 September
2005.
</span>
<!--End of Navigation Panel-->
See
<i><a href=
"about.html">About this document...
</a></i> for information on suggesting changes.