Class Variable Access and Assignment
stefan.arentz at gmail.com
Fri Nov 4 11:04:58 CET 2005
Antoon Pardon <apardon at forel.vub.ac.be> writes:
> Op 2005-11-03, Mike Meyer schreef <mwm at mired.org>:
> > Antoon Pardon <apardon at forel.vub.ac.be> writes:
> >>> What would you expect to get if you wrote b.a = b.a + 2?
> >> I would expect a result consistent with the fact that both times
> >> b.a would refer to the same object.
> > Except they *don't*. This happens in any language that resolves
> > references at run time.
> Python doesn't resolve references at run time. If it did the following
> should work.
> a = 1
> def f():
> a = a + 1
No that has nothing to do with resolving things at runtime. Your example
does not work because the language is very specific about looking up
global variables. Your programming error, not Python's shortcoming.
More information about the Python-list