Accessing docstrings at runtime?

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Wed Aug 29 09:35:48 EDT 2007


Chris Mellon a écrit :
> On 8/29/07, Kenneth Love <klove at tax.ok.gov> wrote:
> 
>>How do I print the docstring for a class property?
(snip)
> 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__

Or type(y).x.__doc__ if you don't know the class of y.



More information about the Python-list mailing list