Class Variable Access and Assignment

Christopher Subich spam.csubich+spam+block at subich.nospam.com
Sun Nov 6 12:23:02 EST 2005


Bengt Richter wrote:
> On Fri, 04 Nov 2005 10:28:52 -0500, Christopher Subich <csubich.spam.block at spam.subich.block.com> wrote:

>>is very much within the language specification.  Indeed, the language 
>>specification dictates that an instance variable b.a is created if one 
>>didn't exist before; this is true no matter if type(b.a) == int, or if 
>>b.a is some esoteric mutable object that just happens to define 
>>__iadd__(self,type(other) == int).
> 
> But if it is an esoteric descriptor (or even a simple property, which is
> a descriptor), the behaviour will depend on the descriptor, and an instance
> variable can be created or not, as desired, along with any side effect you like.

Right, and that's also language-specification.  Voodoo, yes, but 
language specification nonetheless. :)



More information about the Python-list mailing list