Reputation: 12672
It is my understanding that a module docstring should just provide a general description of what a module does and details such as author and version should only be contained in the module's comments.
However, I have seen the following in comments and docstrings:
__author__ = "..."
__version__ = "..."
__date__ = "..."
Where is the correct location to put items such as these? What other __[name]__
variables are common to list at the top of modules?
Upvotes: 16
Views: 5558
Reputation: 7892
I would suggest not to worry about __author__
, __version__
, etc. Those attributes are handled by any decent version control system anyway. Only add them if you need to have that information on a production system, where the source code has already been exported out of the version control system.
Upvotes: 3
Reputation: 123662
They are merely conventions, albeit quite widely-used conventions. See this description of a set of Python metadata requirements.
__version__
is mentioned in the Python Style Guide.
Regarding docstrings, there's a PEP just for you!
The docstring for a module should generally list the classes, exceptions and functions (and any other objects) that are exported by the module, with a one-line summary of each. (These summaries generally give less detail than the summary line in the object's docstring.) The docstring for a package (i.e., the docstring of the package's init.py module) should also list the modules and subpackages exported by the package.
Upvotes: 8