Op 2005-11-04, Stefan Arentz schreef <[EMAIL PROTECTED]>: > Antoon Pardon <[EMAIL PROTECTED]> writes: > >> Op 2005-11-03, Mike Meyer schreef <[EMAIL PROTECTED]>: >> > Antoon Pardon <[EMAIL PROTECTED]> 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 >> >> f() > > 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.
It has nothing to do with global variables, the same thing happens with nested scopes. def f(): a = 1 def g(): a = a + 1 g() f() -- http://mail.python.org/mailman/listinfo/python-list