小编Edv*_*rov的帖子

与c ++ 11中的boost :: mpl :: if_类似

boost::mpl::if_在C++中是否有替代品?我没有机会使用提升.

c++ boost metaprogramming c++11

2
推荐指数
1
解决办法
612
查看次数

Python类方法装饰器

我为类方法编写了一个装饰器

def decor(method):
    def wrapped(self, *args, **kwargs):
        return method(self, *args, **kwargs)
    # [*]
    return wrapped
Run Code Online (Sandbox Code Playgroud)

我想用这个:

class A(metaclass=mymetaclass):
    @decor
    def meth(self):
        pass
Run Code Online (Sandbox Code Playgroud)

我如何在装饰器中添加方法/变量到具有装饰方法的类?我需要它做近[*].里面裹着我可以写self.__class__,但在这做什么?

python python-decorators

0
推荐指数
1
解决办法
838
查看次数

标签 统计

boost ×1

c++ ×1

c++11 ×1

metaprogramming ×1

python ×1

python-decorators ×1