Nested function scope problem

Duncan Booth duncan.booth at invalid.invalid
Tue Aug 1 10:39:39 EDT 2006


Antoon Pardon wrote:

> Even this doesn't:
> 
>   def foo():
>     if False:
>       a = 1
>     else:
>       b = a
> 
>   a = 1
>   foo()
> 
> Yet seems to work (which I think is an error in the optimisation;

What definition of 'seems to work' are you using? It throws an 
UnboundLocalError exception so you'll know pretty quickly that something is 
wrong.



More information about the Python-list mailing list