def _add_class_type(cls, type, inits, proxied): def setter(self, xcls):
setattr(self, type + '_class', xcls)
for m in inits:
self.mdic[m] = xcls
for m in proxied:
if hasattr(xcls, m):
self.mdic[m] = self.proxyclass(m)
1 回答
慕桂英546537
TA贡献1848条经验 获得超10个赞
你漏了一行代码,这个方法是
def _add_class_type(cls, type, inits, proxied): def setter(self, xcls): setattr(self, type + '_class', xcls) for m in inits: self.mdic[m] = xcls for m in proxied: if hasattr(xcls, m): self.mdic[m] = self.proxyclass(m) setattr(cls, 'set_' + type + '_class', setter)
这个方法简单来说,就是把基础类和其他类的方法映射为本对象的方法,类似一个FACADE。
添加回答
举报
0/150
提交
取消