recipe-498259.py 文件源码

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

项目:code 作者: ActiveState 项目源码 文件源码
def consumer(func):
    """A decorator, advances func to its first yield point when called.

    Modifed this original example code from PEP 342 to use the new
    functools.wraps decorator. This convenience function makes it look
    like the original function, which is almost always what we want,
    especially if we designed the original function to be wrapped in
    the first place!

    Maybe `consumer` should go into functools too!
    """

    from functools import wraps

    @wraps(func)
    def wrapper(*args,**kw):
        gen = func(*args, **kw)
        gen.next()
        return gen
    return wrapper
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号