strange behaivor of nested function

1989lzhh 1989lzhh at gmail.com
Sat Jun 7 07:17:23 EDT 2014


here is code

def make():
    def jit(sig):
        def wrap(function):
            sig=sig[0] # unbound local error, if change to sig='' would be just fine
            return function 
        return wrap
    return jit
jit=make()
@jit('')
def f():
    pass

It is strange that the interpreter complain about unbound local error. 
please give me some suggestion, thanks!
Ps: I am using python 2.7
                                  Liu Zhenhai


       

发自我的 iPhone


More information about the Python-list mailing list