Docstrings for class attributes

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Tue Sep 23 03:01:57 EDT 2008


Tom Harris a écrit :
> Greetings,
> 
> I want to have a class as a container for a bunch of symbolic names
> for integers, eg:
> 
> class Constants:
>     FOO = 1
>     BAR = 2

Do you have a reason to stuff them in a class ? Usually, putting them at 
the top level of a module is quite enough...

> Except that I would like to attach a docstring text to the constants,
> so that help(Constants.FOO) will print some arbitrary string.

You can document them in the module or class docstring...




More information about the Python-list mailing list