Module pydoc
[hide private]
[frames] | no frames]

Module pydoc

Generate Python documentation in HTML or text for interactive use.

In the Python interpreter, do "from pydoc import help" to provide online
help.  Calling help(thing) on a Python object documents the object.

Or, at the shell command line outside of Python:

Run "pydoc <name>" to show documentation on something.  <name> may be
the name of a function, module, package, or a dotted reference to a
class or function within a module or module in a package.  If the
argument contains a path segment delimiter (e.g. slash on Unix,
backslash on Windows) it is treated as the path to a Python source file.

Run "pydoc -k <keyword>" to search for a keyword in the synopsis lines
of all available modules.

Run "pydoc -p <port>" to start an HTTP server on a given port on the
local machine to generate documentation web pages.

For platforms without a command line, "pydoc -g" starts the HTTP server
and also pops up a little window for controlling it.

Run "pydoc -w <name>" to write out the HTML documentation for a module
to a file named "<name>.html".

Module docs for core modules are assumed to be in

This can be overridden by setting the PYTHONDOCS environment variable
to a different URL or to a local directory containing the Library
Reference Manual pages.

Version: $Revision: 50881 $

Date: 26 February 2001

Author: Ka-Ping Yee <>

Classes [hide private]
Errors that occurred while trying to import something to document it.
Class for safely making an HTML representation of a Python object.
Formatter class for HTML documentation.
Class for safely making a text representation of a Python object.
Formatter class for text documentation.
A generic tree iterator.
An interruptible scanner that searches module synopses.
Functions [hide private]
Convert sys.path into a list of absolute, existing, unique paths.
Get the doc string or comments for an object.
Split a doc string into a synopsis line (if any) and the rest.
classname(object, modname)
Get a class name and qualify it with a module name if necessary.
Check if an object is of a type that probably means it's data.
replace(text, *pairs)
Do a series of global replacements on a string.
cram(text, maxlen)
Omit part of a string if needed to make it fit in a maximum length.
Remove the hexadecimal id from a Python object representation.
_split_list(s, predicate)
Split sequence s via predicate, and return pair ([true], [false]).
visiblename(name, all=None)
Decide whether to show documentation on a variable.
Wrap inspect.classify_class_attrs, with fixup for data descriptors.
Guess whether a path refers to a package directory.
synopsis(filename, cache={})
Get the one-line summary out of a module file.
Import a Python source file or compiled file given its path.
safeimport(path, forceload=0, cache={})
Import a module; handle errors; return None if the module isn't found.
The first time this is called, determine what kind of pager to use.
Decide what method to use for paging through text.
Remove boldface formatting from text.
pipepager(text, cmd)
Page through text by feeding it to another program.
tempfilepager(text, cmd)
Page through text by invoking a program on a temporary file.
Page through text on a text terminal.
Simply print unformatted text.
Produce a short description of the given thing.
locate(path, forceload=0)
Locate an object by name or dotted path, importing as necessary.
resolve(thing, forceload=0)
Given an object or a path to an object, get the object and its name.
doc(thing, title='Python Library Documentation: %s', forceload=0)
Display text documentation, given an object or a path to an object.
writedoc(thing, forceload=0)
Write HTML documentation to a file in the current directory.
writedocs(dir, pkgpath='', done=None)
Write out HTML documentation for all modules in a directory tree.
Print all the one-line module summaries that contain a substring.
serve(port, callback=None, completer=None)
Graphical interface (starts web server and pops up a control window).
Command-line interface (looks at sys.argv to decide what to do).
Variables [hide private]
  __credits__ = 'Guido van Rossum, for an excellent programming ...
  _re_stripid = re.compile(r'(?i) at 0x[0-9a-f]{6,16}(>+)$')
  text = TextDoc()
  html = HTMLDoc()
  help = <pydoc.Helper instance>

Imports: sys, imp, os, re, types, inspect, __builtin__, pkgutil, Repr, expandtabs, find, join, lower, split, strip, rfind, rstrip, deque

Function Details [hide private]

_split_list(s, predicate)

Split sequence s via predicate, and return pair ([true], [false]).

The return value is a 2-tuple of lists,
    ([x for x in s if predicate(x)],
     [x for x in s if not predicate(x)])

safeimport(path, forceload=0, cache={})


Import a module; handle errors; return None if the module isn't found.

If the module *is* found but an exception occurs, it's wrapped in an ErrorDuringImport exception and reraised. Unlike __import__, if a package path is specified, the module at the end of the path is returned, not the package at the beginning. If the optional 'forceload' argument is 1, we reload the module from disk (unless it's a dynamic extension).



Simply print unformatted text. This is the ultimate fallback.

Variables Details [hide private]


'''Guido van Rossum, for an excellent programming language.
Tommy Burnette, the original creator of manpy.
Paul Prescod, for all his work on onlinehelp.
Richard Chamberlain, for the first implementation of textdoc.