CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
jackfrued

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: jackfrued/Python-100-Days
Path: blob/master/Day01-15/code/Day09/diamond.py
Views: 729
1
"""
2
多重继承
3
- 菱形继承(钻石继承)
4
- C3算法(替代DFS的算法)
5
6
Version: 0.1
7
Author: 骆昊
8
Date: 2018-03-12
9
"""
10
11
12
class A(object):
13
14
def foo(self):
15
print('foo of A')
16
17
18
class B(A):
19
pass
20
21
22
class C(A):
23
24
def foo(self):
25
print('foo fo C')
26
27
28
class D(B, C):
29
pass
30
31
32
class E(D):
33
34
def foo(self):
35
print('foo in E')
36
super().foo()
37
super(B, self).foo()
38
super(C, self).foo()
39
40
41
if __name__ == '__main__':
42
d = D()
43
d.foo()
44
e = E()
45
e.foo()
46
47