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?
What Are the Different Types of Comments in Python? There are three types of comments: single-line, multi-line, and docstring comments.
Convention means a certain way in which things are done within a community to ensure order. Similarly, Coding conventions are also a set of guidelines, but for a programming language that recommends programming style, practices, and methods.
A comment in Python starts with the hash character, # , and extends to the end of the physical line. A hash character within a string value is not seen as a comment, though. To be precise, a comment can be written in three ways - entirely on its own line, next to a statement of code, and as a multi-line comment block.
Comment Syntax Comments in Python begin with a hash mark ( # ) and whitespace character and continue to the end of the line.
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.
You could have a look at:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With