bug in python's scope handling?
Philipp Weinfurter
philipprw at gmx.at
Wed Jul 18 14:14:56 EDT 2001
hi everyone!
a = 1
def func1():
b = a + 1
right, the local variable b is assigned the value of the global variable
a. so far, so good.
def func2():
a = a + 1
and now the local variable a is assigned... uh, nothing because it produces
an UnboundLocalError.
now, i admit that no programmer should ever write such code, but i still
consider this a bug. what _should_ happen, is this: the right side of
the assignment is evaluated first, thus adding 1 to the value of the global
variable a, then the result should be assigned to the local variable a,
no?
then
More information about the Python-list
mailing list