链式调用原理实现
1 链式调用(jq),用python实现链式调用 (对象hello.world.add)
class ChainMethods(object):
def init(self, name):
self.name = name
@property
def hello(self):
print(f'你好{self.name}的')
return self
def world(self):
print("世界")
return self
world = property(world)
def add(self):
print("你吃了吗")
return self
c = ChainMethods('egon')
c.hello.world.add()