views:

1001

answers:

4

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."""
    pass

But what about a module? How can I document what a file.py does?

+2  A: 

It's easy, you just add a docstring at the top of the module.

David Locke
+13  A: 

For the packages, you can document it in __init__.py. For the modules, you can add a docstring simply in the module file.

All the information is here: http://www.python.org/dev/peps/pep-0257/

Grégoire Cachet
+3  A: 

You do it the exact same way. Put a string in as the first statement in the module.

Chris Upchurch
A: 

Ok, thank you for your quick answers :)

Auron