From the Python language reference (v 3.1 see here - http://docs.python.org/py3k/reference/executionmodel.html#naming-and-binding ):
It is incorrect to undo the name referenced by the closing region; the compiler will report a SyntaxError error.
But when I run the following code:
a = 3 def x(): global a del(a) print(a) x()
it works great; and when I change the order of calls:
x() print(a)
I get a NameError, not a SyntaxError. Apparently, I misunderstand the rule. Can anyone explain this? Thank you
python syntax-error unbind
user500944
source share