callback confusion

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Sat Dec 8 12:01:29 EST 2007


Donn Ingle a écrit :
(snip)
> [in one.py]
> kills=0
> def boo():
>  print kills
> 
> It will abort with:
>     print kills
> UnboundLocalError: local variable 'kills' referenced before assignment

As far as I can tell, you have a bit more code in boo, and somewhere in 
that code (after the print statement), you rebind the name 'kills'. In 
the absence of a global declaration, this makes this name a local 
variable. FWIW, this is a FAQ.



More information about the Python-list mailing list