pythondocumentationpydoc

How to populate various aspects in help()


In looking at help() on a few different modules, it often lists the following items:

Module Docs:

MODULE DOCS
    http://docs.python.org/library/os

Classes:

CLASSES
    __builtin__.object
        posix.stat_result

Data:

DATA
    EX_CANTCREAT = 73

Version:

VERSION
    (7, 0, 2)

How are these four items created?


Solution

  • Help texts are extracted from the python files's doctrings by the pydoc module. You can read more about pydoc on the Python Devguide.
    Pydoc extracts information about the module, for example which classes and functions are defined, what data, et cetera.

    Try running for example pydoc os (or help(os)) and compare it to the module source code: /usr/lib/python3.7/os.py