recipe-576751.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:code 作者: ActiveState 项目源码 文件源码
def runtime(f):
    """Evaluates the given function each time it is called."""
    # get the function's name
    name = f.__name__
    # and its source code, sans decorator
    source = remove_decorators(getsource(f))
    @wraps(f)
    def wrapped(*args, **kwargs):
        # execute the function's declaration
        exec(source)
        # since the above overwrites its name in the local
        # scope we can call it here using eval
        return eval("%s(*%s, **%s)" % (name, args, kwargs))
    return wrapped
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号