Python Docstrings

In Python, Docstrings is also known as Documentation Strings. It is very important as they help tools automatically generate online or printed documentation. It also helps users and readers of the code interactively browse through the code. It is created by putting a multiline string to explain the function. It has the following syntax:

def function-name(parameters):
function statements
return [expression]

Properties of Docstrings:

1. As the first line, Docstrings should always be short highlighting the summary of the object’s purpose.
2. It should not specify information like the object’s name or type.
3. It should begin with a capital letter and end with a period.
4. Triple quotes are used to extend the docstring to multiple lines. This docstring specified can be accessed through the __doc__ attribute of the function.
5. In the case of multiple lines in the documentation string, the second line should be blank, to separate the summary from the rest of the description.
6. The first non-blank line after the first line of the documentation string determines the amount of indentation
for the entire documentation string.


def func():
"""Hi! Welcome to Webeduclick"""
print("Hello World!")


Hi! Welcome to Webeduclick