in Python by
Q:
What is docstring in Python?

2 Answers

0 votes
by

A Python documentation string is known as docstring, it is a way of documenting Python functions, modules and classes.

0 votes
by

Python docstrings are the string literals enclosed in triple quotes that appear right after the definition of a function, method, class, or module. These are generally used to describe the functionality of a particular function, method, class, or module. We can access these docstrings using the __doc__ attribute. Here is an example:

def square(n):

    '''Takes in a number n, returns the square of n'''

    return n**2

print(square.__doc__)

 Ouput: Takes in a number n, returns the square of n 

Click here to read more about Python
Click here to read more about Insurance

Related questions

0 votes
asked Jun 29, 2020 in Python by Robindeniel
+1 vote
asked Feb 13 in Python by SakshiSharma
0 votes
asked Jan 18 in Python by SakshiSharma
0 votes
asked Jan 1 in Python by SakshiSharma
0 votes
0 votes
asked Aug 30, 2020 in Python by sharadyadav1986
...