How to write function document string
Documenting Functions
To document a function we have two ways. One way is to use comment which start with #. Another way is to use function doc.
The function doc string is right after the def statement.
We can access docstring with __doc__
property
of the function.
The double underscores in the attribute name indicate that the property is a special property value.
def square(x): # w w w . j a va 2s .c o m
'Calculates the square of the number x.'
return x*x
print square.__doc__
The code above generates the following result.