Class Variable Access and Assignment
stefan.arentz at gmail.com
Thu Nov 3 16:30:44 CET 2005
Antoon Pardon <apardon at forel.vub.ac.be> writes:
> Op 2005-11-03, Stefan Arentz schreef <stefan.arentz at gmail.com>:
> > 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
> That is an explanation, not a reason.
I'm just following the
> > 1. get 't'b.a and store it in a temporary 't' (found the instance)
> > 2. add 2 to 't'
> > 3. store 't' in 'b.a'
> > The last operation stores it into an instance variable.
> [ I think you mean '(found the class variable)' in line 1 ]
> All you are doing here is explain how the current implemantation treats
> this. You are not giving arguments for why the result of this
> implementation should be considered sane behaviour.
Ah yes. Well, good luck with that. You seem to have decided that it is not
sane and who am I to argue with that. It depends on your state of mind :-)
The model makes sense in my opinion. If you don't like it then there are
plenty of other languages to choose from that have decided to implement
Have fun, take care!
More information about the Python-list