Docstrings for class attributes

Tom Harris celephicus at gmail.com
Tue Sep 23 07:23:35 CEST 2008


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

Except that I would like to attach a docstring text to the constants,
so that help(Constants.FOO) will print some arbitrary string. Sort of
a very limited implementation of PEP 224. The only solution that I can
see is to subclass int.__new__(), since once I have an int all it's
attributes are immutable.

-- 

Tom Harris <celephicus(AT)gmail(DOT)com>



More information about the Python-list mailing list