Docstrings in Python
The docstring is an in-built feature of Python, which is used to associate documentation that has been written with Python modules, functions, classes, and methods. It is added right below the functions, modules, or classes to describe what they do. In Python, the docstring is then made available via the Python __doc__ attribute.
Example: Docstrings in Python
In this example, after multiply() function is defined, we declared a docstring comment using the triple quotes. Then we are printing the docstring using the __doc__ attribute.
def multiply(a, b):
"""Multiplies the value of a and b"""
return a*b
# Print the docstring of multiply function
print(multiply.__doc__)
Output:
Multiplies the value of a and b
Multiline comments in Python
In this article, we will delve into the concept of multiline comments in Python, providing a comprehensive definition along with illustrative examples in the Python programming language on How to Comment Multiple lines in Python.