Why property works only for objects?

Alex Martelli aleaxit at yahoo.com
Sat Mar 11 03:49:29 CET 2006


Michal Kwiatkowski <ruby at no.spam> wrote:
   ...
> Let me understand it clearly. If I change __class__ of an object,
> existing attributes (so methods as well) of an object are still
> accessible the same way and don't change its values. Only resolution of
> attributes/methods not found in object is changed, as it uses new
> version of __class__ to lookup names. Is this right?

Attributes of the _instance_ are unchanged.  Anything that would
normally be looked up in the OLD __class__, such as methods, is gone:
which is why you normally set as the NEW __class__ some subclass of the
old one, so that nothing is really gone;-).


Alex



More information about the Python-list mailing list