-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoopinheritance.py
More file actions
62 lines (44 loc) · 1014 Bytes
/
coopinheritance.py
File metadata and controls
62 lines (44 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
class AA:
def __init__(self):
print(f"start AA.__init__ {self.__dict__}")
self.aa = True
super().__init__()
def ff(self):
print("AA.ff")
class A(AA):
def __init__(self):
print(f"start A.__init__ {self.__dict__}")
self.xx = 9
super().__init__()
super().ff()
print(A.__mro__)
def f(self):
print("A.f")
class B(AA):
def __init__(self):
print(f"start B.__init__ {self.__dict__}")
self.b = True
super().__init__()
def f(self):
print("B.f")
def ff(self):
print("B.ff")
class C(A, B):
def __init__(self):
print(f"start C.__init__ {self.__dict__}")
super().__init__()
print(f"end C.__init__ {self.__dict__}")
super().f()
C()
class A1:
def f(self):
print("A1.f")
def g(self):
print("A1.g")
self.f()
class B1(A1):
def f(self):
print("B1.f")
super().f()
b1 = B1()
b1.g()