If you simply do, help(help)
, you will get
Help on _Helper in module site object:
class _Helper(__builtin__.object)
| Define the builtin 'help'.
| This is a wrapper around pydoc.help (with a twist).
|
| Methods defined here:
|
| __call__(self, *args, **kwds)
|
| __repr__(self)
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
basically, help
gets its input from pydoc.help
. Quoting, pydoc
documentation,
For modules, classes, functions and methods, the displayed documentation is derived from the docstring (i.e. the __doc__
attribute) of the object, and recursively of its documentable members. If there is no docstring, pydoc
tries to obtain a description from the block of comment lines just above the definition of the class, function or method in the source file, or at the top of the module (see inspect.getcomments()
).
The built-in function help()
invokes the online help system in the interactive interpreter, which uses pydoc
to generate its documentation as text on the console.
But where exactly does it find the information it shows?
The quoted bold text above answers this question.