Abstract This PEP documents the semantics and conventions associated with Python docstrings. The PEP contains conventions, not laws or syntax. A universal convention supplies all of maintainability, clarity, consistency, and a foundation for good programming habits too. What it doesn’t do is insist that you follow it against your will.
If you violate these conventions, the worst you’ll get is some dirty looks. A docstring is a string literal that occurs as the first statement in a module, function, class, or method definition. Such a docstring becomes the __doc__ special attribute of that object. All modules should normally have docstrings, and all functions and classes exported by a module should also have docstrings. A package may be documented in the module docstring of the __init__.
String literals occurring elsewhere in Python code may also act as documentation. String literals occurring immediately after a simple assignment at the top level of a module, class, or __init__ method are called “attribute docstrings”. String literals occurring immediately after another docstring are called “additional docstrings”.