後來發現缺少的self,可以透過Descriptor把它加回來
===========================
class T1(object):
def __init__(self, func):
self.func = func
def __get__(self, obj, cls=None):
self.obj = obj
return self
def __call__(self, *arg, **kw):
return self.func(self.obj, *arg, **kw)
class A(object):
x = 2
@T1
def func(self):
print(self.x)
a = A()
a.func()
==============================