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)


Output

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.

Similar Reads

help() function in Python Syntax

Syntax: help([object]) Parameters (Optional) : Any object for which we want some help or the information....

What is Help function in Python?

The Python help function is used to display the documentation of modules, functions, classes, keywords, etc. It provides information about modules, classes, functions, and methods. It is a useful tool for getting documentation and assistance on various aspects of Python....

Python help() function Examples

Simple help() Program...

Python help() function docstring

...