Python help() function docstring
The docstrings are declared using ”’triple single quotes”’ or “””triple double quotes””” just below the class, method or function declaration. All functions should have a docstring.
Accessing Docstrings: The docstrings can be accessed using the __doc__ method of the object or using the help function.
Python3
def my_function(): '''Demonstrates triple double quotes docstrings and does nothing really.''' return None print ( "Using __doc__:" ) print (my_function.__doc__) print ( "Using help:" ) help (my_function) |
Using __doc__: Demonstrates triple double quotes docstrings and does nothing really. Using help: Help on function my_function in module __main__: my_function() Demonstrates triple double quot...
Help function in Python
In Python, the help()
function is a built-in function that provides information about modules, classes, functions, and modules. In this article, we will learn about help function in Python.