Python 3 reference · Built-in Functions
Python help() Function
Show the built-in help for a function, class, module or keyword: its signature and documentation. Mostly used in the REPL.
Python 3 Since 3.0
Syntax
help()
help(request)
Parameters
| Parameter | Description |
|---|---|
request optional |
An object, or a string naming a module, keyword or topic. |
Return value
None; the help text is printed.
Examples
def area(width, height):
"""Return the area of a rectangle."""
return width * height
help(area)
Output
Help on function area:
area(width, height)
Return the area of a rectangle.print(len.__doc__) # the same documentation, as a string
Output
Return the number of items in a container.
Good to know
In the REPL, help() with no argument starts an interactive help system; type quit to leave. Write
docstrings (the first string in a function or class) so help() has something useful to show.
Version history
| Version | Change |
|---|---|
| Python 3.0 | Added |
Related
dir()· List the names an object has, such as attributes and methods. With no argument, list the names in the current scope.vars()· Return the __dict__ of a module, class or object: its writable attributes as a dictionary. With no argument, like locals().- Python Functions · tutorial