当我为类方法创建装饰器时,它总是接收类型为“function”的方法。为什么Python类方法装饰器不能将该方法作为绑定方法接收?
然而,当我玩的东西了一下,我只拿回绑定方法:
class Test(object):
def save(self):
print "Save called"
def func(self):
print "Func called"
然后:
>>> type(Test.func)
<type 'instancemethod'>
>>> type(Test().func)
<type 'instancemethod'>
我最终会做的是创建一个类方法装饰器,它也在同一个类上装饰了一些其他方法。我会如何去做这件事?
'Test.func'不是一个绑定的方法。 –