How to comment constant values?
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Sun Jul 26 19:23:30 EDT 2009
On Mon, 27 Jul 2009 00:47:08 +0200, Diez B. Roggisch wrote:
>> Only modules, classes, and functions/methods can have docstrings
>> associated with them.
>> For anything else, you have to use comments; or you can mention them in
>> the docstrings of related things.
>
> While this is technically true, writing docstrings to constants (module
> or classlevel) works when one uses tools such as epydoc to generate
> documentation.
I've never used epydoc, so I'm not sure what you mean. Presumably it uses
source code analysis to detect:
CONSTANT = 42
"""This is a constant."""
even though the string is ignored by the compiler.
Is that correct?
--
Steven
More information about the Python-list
mailing list