functools.wraps 在python 2.4中不可用.在python 2.4中是否还有其他模块可以代替这个?
您可以从Python2.5复制functools代码并使其在Python2.4中工作,只需进行少量更改(将lambda替换为部分代码):http: //hg.python.org/cpython/file/b48e1b48e670/Lib/functools的.py#L15
这是部分的简单替代:
def partial(func, *args, **kwds):
"Emulate Python2.6's functools.partial"
return lambda *fargs, **fkwds: func(*(args+fargs), **dict(kwds, **fkwds))
Run Code Online (Sandbox Code Playgroud)