python override筆記 其他特殊流程
這邊紀錄python繼承的其他特殊流程 父類別呼叫子類別的函數 In: class Demo: def __demoprint(self): print('__demoprint') def demoprint_(self): print('demoprint_') def demo(self): print('demo') self.__demoprint() self.demoprint_() class Demo1(Demo): def __init__(self): super().__init__() def __demoprint(self): print('__demo2print') def demoprint_(self): print('demo2print_') def demo1(self): print('demo1') super().demo() d=Demo1() d.demo1() Out: demo1 demo __demoprint demo2print_ 再去call父類別function In: class Demo: def DemoF1(self): print("DemoF1") def DemoF2(self): self.DemoF1() print("DemoF2") class Demo2(Demo): def DemoF1(self): print("Demo1F1") super().DemoF1() def Demo2F1(self): print('Demo2F1') super().DemoF2() d = Demo2() d.Demo2F1...