Mega Code Archive

 
Categories / Python Tutorial / Function
 

Documenting Functions

#  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)