设计模式-结构型模式之代理
解耦调用方与被调用方之间的关系
1 class Valley: 2 3 def test(self): 4 print(1) 5 6 7 class Proxy: 8 """代理类""" 9 10 def __init__(self, real_obj): 11 self.proxy = real_obj 12 13 def func(self): 14 self.proxy.test() 15 16 17 if __name__ == '__main__': 18 Proxy(Valley()).func()
浙公网安备 33010602011771号