Re: Unbinding a name referenced by an enclosing scope

2011-02-20 Thread Peter Otten
Grigory Javadyan wrote: >>From the Python Language Reference (v 3.1): > >> It is illegal to unbind a name referenced by an enclosing scope; the >> compiler will report a SyntaxError. > > But when I run the following code: > > a = 3 > def x(): > global a > del(a) > > print(a) > x() > > it

Unbinding a name referenced by an enclosing scope

2011-02-20 Thread Grigory Javadyan
>From the Python Language Reference (v 3.1): > It is illegal to unbind a name referenced by an enclosing scope; the compiler > will report a SyntaxError. But when I run the following code: a = 3 def x(): global a del(a) print(a) x() it works fine; and when I change the order of calls: x(