Docstrings for class attributes

Terry Reedy tjreedy at udel.edu
Tue Sep 23 14:36:29 EDT 2008


Peter Pearson wrote:
> On Tue, 23 Sep 2008 15:23:35 +1000, Tom Harris <celephicus at gmail.com> wrote:
>> 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.
> [snip]
> 
> Commiserating, not helping: I have a similar problem with a module
> that holds values of physical constants,
> http://webpages.charter.net/curryfans/peter/nature.py:
> 
> boltzmanns_constant = 1.380622e-16 * erg / k
> stefan_boltzmann_constant = 5.66961e-5 * erg/s/cm/cm/k/k/k/k
> gravitational_constant = 6.6732e-8 * erg*cm/g/g
> 
> I would like to reveal more details with, e.g.,
> help( gravitational_constant ) . . . and maybe then I could
> use shorter names.

gravitational_constant = g = 6.6732e-8 * erg*cm/g/g
...




More information about the Python-list mailing list