docstrings for data fields
Jean-Michel Pichavant
jeanmichel at sequans.com
Thu May 3 11:00:25 EDT 2012
Ulrich Eckhardt wrote:
> Hi!
>
> My class Foo exports a constant, accessible as Foo.MAX_VALUE. Now, with
> functions I would simply add a docstring explaining the meaning of this,
> but how do I do that for a non-function member? Note also that ideally,
> this constant wouldn't show up inside instances of the class but only
> inside the class itself.
>
> There are decorators for static functions or class functions, similarly
> there is one for instance properties but there isn't one for class
> properties. Would that be a useful addition?
>
> Uli
>
class Foo:
MAX_VALUE = 42
"""The maximum value"""
epydoc support such docstring.
If you need a native support for the python help function for instance,
document it within the class docstring:
class Foo:
"""Foo support
Attributes:
MAX_VALUE: the maximum value
"""
MAX_VALUE = 42
More information about the Python-list
mailing list