Documenting Functions : Documentation « Function « Python Tutorial






# If you put a string at the beginning of a function, it is stored as part of the function and is called a docstring. 
# __doc__ is a function attribute. 
# The double underscores mean that this is a special attribute. 

def square(x):
   'Calculates the square of the number x.'
   return x*x 

# The docstring may be accessed like this: 
print square.__doc__


help(square)








10.8.Documentation
10.8.1.Documenting Functions
10.8.2.Special comments called documentation strings, or "doc strings"
10.8.3.Doc Strings