我写一个装饰类方法Python类方法装饰
def decor(method):
def wrapped(self, *args, **kwargs):
return method(self, *args, **kwargs)
# [*]
return wrapped
我想利用这个样:
class A(metaclass=mymetaclass):
@decor
def meth(self):
pass
我怎能方法/变量装饰添加到已装修方法类?我需要它在[*]
附近做。 里面裹着我可以写self.__class__
,但在这里做什么?
你可以用'method.im_class' http://stackoverflow.com/questions/7680446/get-python-functions-owning-class-from-decorator –