LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

pydoc

View Python module documentation

TLDR

View documentation for a module
$ pydoc [module]
copy
View documentation for a class or function
$ pydoc [module.ClassName]
copy
Search module synopses for a keyword
$ pydoc -k [keyword]
copy
Start a local documentation HTTP server
$ pydoc -p [8080]
copy
Start server and open in the default browser
$ pydoc -b
copy
Write HTML documentation to a file in the current directory
$ pydoc -w [module]
copy

SYNOPSIS

pydoc [-k keyword] [-p port] [-b] [-w] [name...]

DESCRIPTION

pydoc is Python's built-in documentation tool that displays module documentation generated from docstrings and introspection. It can show documentation for modules, classes, functions, and keywords in the terminal, search across all installed modules with -k, or generate static HTML files with -w.The -p flag starts a local HTTP documentation server that provides a browsable interface to all installed Python modules, and -b opens this server automatically in the default web browser. pydoc is part of the Python standard library and provides the same functionality as the interactive help() function.The PAGER environment variable controls which program is used for terminal display. The BROWSER environment variable controls which browser is used with -b.

PARAMETERS

name

Module, package, class, function, or keyword to document.
-k keyword
Search synopsis lines of all available modules for keyword.
-p port
Start HTTP documentation server on the given port.
-b
Start HTTP server and open a web browser to its page.
-w name
Write HTML documentation for the module to a file in the current directory.
-n host
Hostname for the HTTP server (default: localhost). Python 3.11+.

CAVEATS

Documentation quality depends on the presence of docstrings in the module source. Importing a module to inspect it may execute module-level code. The -n flag for specifying the server hostname requires Python 3.11+.

HISTORY

pydoc has been part of the Python standard library since Python 2.1 (2001). It was written by Ka-Ping Yee as a built-in documentation viewer, providing the same functionality as the interactive help() function.

SEE ALSO

python(1), help(1), pydoc3(1)

Copied to clipboard
Kai