PythonBuilt-in functions
help()
Displays the built-in documentation for an object, function, or module.
- Returns
None(the documentation is displayed).
Example
#Python
def award(name, exp=10):
"""Gives experience points to a student."""
return f"{name}: +{exp} EXP"
help(award)Result
Click Run to see the result.
The result includes the signature award(name, exp=10) and the description from the docstring. The exact look depends on the Python version.
Definition and usage
#The help() function displays documentation for the given object: a description of what it does, its parameters, and its available methods. It works with built-in functions, modules, classes, and your own code.
Documentation for your own functions comes from docstrings placed at the start of a function or class. help() shows them together with the signature.
In interactive mode, calling help() with no argument opens a help browser, which you exit by typing q or quit.
Syntax
#Syntax
help(object)Parameters
#object
optional
A function, module, class, or a string with a topic name.
More examples
#Python
def award(name, exp=10):
"""Gives experience points to a student."""
print(award.__doc__)Resultsaved result, you can check it
Gives experience points to a student.
Good practices
#- Write docstrings for your functions.
help()and code editors will show them to other developers. - For a quick list of an object's methods, use
dir().
Related entries
#Spotted a mistake or missing an example? Write to us.