recipe-164044.py 文件源码

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

项目:code 作者: ActiveState 项目源码 文件源码
def enableAttributes(genfunc):
    """Wrapper for generators to enable classlike attribute access.

    The generator definition should specify 'self' as the first parameter.
    Calls to a wrapped generator should ignore the self parameter.
    """
    old = getargspec(genfunc)
    old[0].pop(0)
    new = getargspec(genfunc)
    new[0][0] = 'wrapped'
    specs = {'name': genfunc.func_name,
         'oldargs': formatargspec(*old),
         'newargs': formatargspec(*new)}
    exec(_redefinition % specs, genfunc.func_globals)


#### A minimal, complete example
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号