Getting the docstring of a property

Andrew Durdin adurdin at gmail.com
Wed Aug 11 14:13:00 CEST 2004


How do you get the docstring of a property? Suppose I have the following:

class Foo:
    def _prop_get(self):
        return 1
    prop = property(_prop_get, doc="This is the docstring")

foo = Foo()
print foo.prop
print foo.prop.__doc__

This will display "1", followed by the docstring for an integer (which
is the docstring for the int() function). How can I get the property's
docstring as defined in the property() function?



More information about the Python-list mailing list