Class: @property -> .__dict__

Thomas Rachel nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de
Fri Dec 16 05:02:51 EST 2011


Am 16.12.2011 09:52 schrieb Ulrich:

> Could anyone please explain me why this does not work / how to get b
> into .__dict__ / hint me to an explanation?

b is not a data element of the particular instance, but it lives in the 
class. It is, roughly spoken, a "kind of method", just to be used 
without calling. These things are called "data descriptors" 
(http://docs.python.org/reference/datamodel.html#descriptors).

t.b is internally reflected to te.__dict__['b'].__get__(t, te) in order 
to call the __get__ method of the property object. This is done on every 
call and the value is, in your case, derived from the instance value a.

HTH,

Thomas



More information about the Python-list mailing list