get descriptor from instance
Alan G Isaac
aisaac at american.edu
Wed Feb 18 17:48:17 EST 2009
What is a reliable way to get the
the property object for an instance attribute?
(Or more generally, to get the descriptor
controlling an attribute?)
If class ``A`` defines the property ``x`` and ``a``
in an instance of ``A``, then you can just use
``type(a).__dict__['x']`` to get the property object.
But this will not work if the property is inherited.
Thanks,
Alan Isaac
More information about the Python-list
mailing list