Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #72910

strange behaivor of nested function

Subject strange behaivor of nested function
From 1989lzhh <1989lzhh@gmail.com>
Date 2014-06-07 19:17 +0800
Newsgroups comp.lang.python
Message-ID <mailman.10849.1402140210.18130.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

strange behaivor of nested function 1989lzhh <1989lzhh@gmail.com> - 2014-06-07 19:17 +0800
  Re: strange behaivor of nested function Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-06-07 15:06 +0000

csiph-web