strange behaivor of nested function
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Sat Jun 7 11:06:30 EDT 2014
On Sat, 07 Jun 2014 19:17:23 +0800, 1989lzhh wrote:
> here is code
>
> def make():
> def jit(sig):
> def wrap(function):
> sig=sig[0] # unbound local error
You are saying:
"sig is a local variable. Assign sig to the value of sig[0]."
But what is sig? You've said it is a local variable, and at this point it
doesn't have a value yet.
Lua allows you to do this:
sig = sig[0]
will look up a global sig and assign it to the local sig first, but that
can be confusing and Python doesn't do that.
--
Steven D'Aprano
http://import-that.dreamwidth.org/
More information about the Python-list
mailing list