next up previous contents index
Next: Global/local variables and module Up: Python basics Previous: The dir() built-in function   Contents   Index

The __doc__ attribute

Each Python object (functions, classes, variables,...) provides (if programmer has filled it) a short documentation which describes its features. You can access it with commands like print myobject.__doc__. You can provide a documentation for your own objects (functions for example) in the body of their definition as a string surrounded by three double-quotes:
>>> def myfunc():
...    """'myfunc' documentation."""
...    pass
...
>>> print myfunc.__doc__
'myfunc' documentation.



Gildas manager 2014-07-01