Hello, today I wrote this piece of code and I am wondering why it does not work the way I expect it to work. Here's the code:
y = 0 def func(): y += 3 func() This gives an UnboundLocalError: local variable 'y' referenced before assignment If I change the function like this: y = 0 def func(): print y func() then no error is thrown and python apparently knows about 'y'. I don't understand why the error is thrown in the first place. Can somebody explain the rule which is causing the error to me? -Matthias -- http://mail.python.org/mailman/listinfo/python-list