Unexpected behavior of read only attributes and super

Samuel M. Smith smithsm at samuelsmith.org
Thu Dec 8 20:36:44 EST 2005


>
>> Then why wasn't __class__ added to c.__dict__ ? Looks like namespace
>> searching to me.
>
> No, as you conclude later, __class__ is special, so you can still  
> assign
> to __class__ even when __slots__ is defined because it's not  
> considered
> a normal attribute.  But note that __class__ is an *instance*  
> attribute,
> not a class attribute, so "c.__class__ = C" changes the class of that
> single instance, and makes no change to the type:
>
> So no, even with __class__, you're only assigning to the instance, and
> so Python's not searching any additional namespaces.

Thank you so much, very helpful comments. I hope it helps others as  
well.
At the very least I now understand a little better about some of the  
special
rules for special attributes.



More information about the Python-list mailing list