Python pydoc: generate documentation and online help
Answer: The pydoc module automatically generates documentation from Python objects.
How documentation is shown
Output can appear as console pages, in a web browser, or as saved HTML files.
For modules, classes, functions and methods, the text comes from the docstring of the object.
The built-in help function uses pydoc to generate console documentation.
You can also run pydoc as a script at the operating system command prompt.
How it locates modules
When printing output to the console, pydoc attempts to paginate the output.
If both MANPAGER and PAGER are set, MANPAGER is used.
The synopsis line of a module is the first line of its documentation string.
Core module docs are assumed to reside under the docs.python.org library pages for this interpreter version.
See also
Claims
- id: C1 claim: The pydoc module automatically generates documentation from Python objects. source: S1 evidence: "pydoc module automatically generates documentation"
- id: C2 claim: The built-in help function uses pydoc for console documentation. source: S1 evidence: "invokes the online help system"
- id: C3 claim: If both pager variables are set, MANPAGER is used. source: S1 evidence: "When both are set, MANPAGER is used"
- id: C4 claim: A module synopsis is the first line of its documentation string. source: S2 evidence: "synopsis line of a module is the first line"
Sources
- [S1] pydoc — Documentation generator and online help system. Python Software Foundation. https://docs.python.org/3/library/pydoc.html . License: PSF License Version 2. Accessed 2026-11-24.
- [S2] pydoc documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/pydoc.rst . License: PSF License Version 2. Accessed 2026-11-24.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, pydoc — Documentation generator and online help system; CPython, pydoc documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, pydoc — Documentation generator and online help system; CPython, pydoc documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.
Cite this
iinventedlight. 2026. "Python pydoc: generate documentation and online help." iinventedlight Library, iil:note:m9wxtvwy, version of 2026-11-24. https://iinventedlight.com/library/notes/python-pydoc/. License: CC-BY-4.0.
@misc{iil_note_m9wxtvwy,
author = {{iinventedlight}},
title = {{Python pydoc: generate documentation and online help}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-24},
url = {https://iinventedlight.com/library/notes/python-pydoc/},
note = {Permanent ID iil:note:m9wxtvwy. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- python-pydoc.schema.json (schema; CC-BY-4.0)
- python-pydoc.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-pydoc.md.