User Access to the docstring of a property

Diez B. Roggisch deets at nospam.web.de
Fri Oct 20 16:25:48 CEST 2006


Colin J. Williams schrieb:
> Is there some way that the user can access the docstring specified for a 
> property?

You need to access it using the class, not an instance of it.

class Foo(object):

     @apply
     def prop():
         def fget(self):
             return 10
         def fset(self, value):
             pass
         doc = "this is a docstring"
         return property(**locals())

f = Foo()
print f.prop


print Foo.prop.__doc__

print f.__class__.prop.__doc__


Diez



More information about the Python-list mailing list