Computer >> Computer tutorials >  >> Programming >> Python

What does built-in class attribute __doc__ do in Python?


All functions have a built-in attribute __doc__, which returns the doc string defined in the function source code.

def foo():
    """ This is an example of how a doc_string looks like.
          This string gives useful information about the function being defined.
    """
    pass
print foo.__doc__

 Let's see how this would look like when we print it

This is an example of how a doc_string looks like.
          This string gives useful information about the function being defined.