Python – How to document a module in Python


That's it. If you want to document a function or a class, you put a string just after the definition. For instance:

def foo():
    """This function does nothing."""

But what about a module? How can I document what a does?

Best Solution

Add your docstring as the first statement in the module.

Your module's verbose yet thorough docstring.

import foo

# ...

For packages, you can add your docstring to