python super

 1 class A:
 2     def test(self):
 3         print("a.test")
 4         super().test()
 5 
 6 
 7 class B:
 8     def test(self):
 9         print("b.test")
10 
11 
12 class C(A, B):
13     def test(self):
14         super().test()
15         print("c.test")
16 
17 
18 if __name__ == '__main__':
19     print(C.__mro__)
20     C().test()
21 """
22 (<class '__main__.C'>, <class '__main__.A'>, <class '__main__.B'>, <class 'object'>)
23 a.test
24 b.test
25 c.test
26 """

 

posted @ 2018-11-28 14:51  两只老虎111  阅读(229)  评论(0编辑  收藏  举报