Accessing docstrings at runtime?

Kenneth Love klove at tax.ok.gov
Wed Aug 29 16:33:02 EDT 2007


On 08/29/07, Chris Mellon <arkanes at gmail.com> wrote:
> On 8/29/07, Kenneth Love <klove at tax.ok.gov> wrote:
>> How do I print the docstring for a class property?
>>
>> [[[ SNIP EXAMPLE ]]]
>>
>> What am I doing wrong?
>>
>
> You're looking at an instance, not at the class. y.x is going through
> the descriptor lookup and is returning the string, so the __doc__ is
> the the __doc__ of the string object, as you see.
>
> If you want to look at the property directly, look it up in the class 
> object:
>
> C.x.__doc__

That worked.  Thanks!

Kenneth 





More information about the Python-list mailing list