此代码按预期工作,但会导致内存泄漏吗?
class Method(object):
method = []
def call(self,method,*args,**kwargs):
kwargs.update({'access_token': self.access_token})
print method,args,kwargs
def __getattr__(self,name):
cp = Method()
cp.access_token = self.access_token
cp.method = self.method + [name]
return cp
def __call__(self,*args,**kwargs):
return self.call('.'.join(self.method),*args,**kwargs)
class Api(Method):
access_token = 'setups on init'
a=Api()
a.get()
a.set(data=1)
或者Method实例调用后会去垃圾吗?