[EMAIL PROTECTED] wrote: > Ping> The question is, what behaviour is preferable for this code: > > Ping> g = 1 > Ping> def f(): > Ping> g += 1 > > Ping> f() > > If you treat "g += 1" as "g = g + 1" then it should create a local variable > with a value of 2.
py> g = 1 py> def f(): ... g = g + 1 ... py> f() Traceback (most recent call last): File "<stdin>", line 1, in ? File "<stdin>", line 2, in f UnboundLocalError: local variable 'g' referenced before assignment Regards, Martin _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com