Thursday, September 26, 2013

variable dis-assignment

>>> def foo():
...    a = 1
...    del a
...    return a
...
>>> foo()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 4, in foo
UnboundLocalError: local variable 'a' referenced before assignment


No comments:

Post a Comment