How can I get access to the function called as a property?

Christian Heimes lists at cheimes.de
Sun May 24 22:08:41 EDT 2009


Matthew Wilson schrieb:
> I use a @property decorator to turn some methods on a class into
> properties.  I want to be able to access some of the attributes of the
> original funtion, but I don't know how to get to it.
> 
> Any ideas?

Here you are:

>>> class Example(object):
...     @property
...     def func(self):
...         pass
...
>>> Example.func.fget
<function func at 0x7fc8d3129938>
>>> example = Example()
>>> example.__class__.func
<property object at 0x7fc8d31309f0>
>>> example.__class__.func.fget
<function func at 0x7fc8d3129938>




More information about the Python-list mailing list