Class Variable Access and Assignment
Stefan Arentz
stefan.arentz at gmail.com
Thu Nov 3 09:37:54 EST 2005
Stefan Arentz <stefan.arentz at gmail.com> writes:
> Antoon Pardon <apardon at forel.vub.ac.be> writes:
>
> ...
>
> > Fine, we have the code:
> >
> > b.a += 2
> >
> > We found the class variable, because there is no instance variable,
> > then why is the class variable not incremented by two now?
>
> Because it really is executed as:
>
> b.a = b.a + 2
>
> 1. get 't'b.a and store it in a temporary 't' (found the instance)
Oops.
1. get b.a and store it in a temporary 't' (found the class variable 'a')
S.
More information about the Python-list
mailing list