Skip to content

Commit a213c99

Browse files
committed
By Zhao Kun Peng
1 parent 0042961 commit a213c99

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

oop/super1.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
class Parent1(object):
2+
def __init__(self):
3+
super().__init__()
4+
print("is Parent1")
5+
print("goes Parent1")
6+
7+
class Parent2(object):
8+
def __init__(self):
9+
super().__init__()
10+
print("is Parent2")
11+
print("goes Parent2")
12+
13+
class Child1(Parent1):
14+
def __init__(self):
15+
print("is Child1")
16+
super().__init__()
17+
#Parent1.__init__(self)
18+
print("goes Child1")
19+
20+
class Child2(Parent1):
21+
def __init__(self):
22+
print("is Child2")
23+
super().__init__()
24+
#Parent1.__init__(self)
25+
print("goes Child2")
26+
27+
class Child3(Parent2):
28+
def __init__(self):
29+
print("is Child3")
30+
super().__init__()
31+
# Parent2.__init__(self)
32+
print("goes Child3")
33+
34+
class Grandson(Child1,Child2,Child3):
35+
def __init__(self):
36+
print("is Grandson")
37+
Child1.__init__(self)
38+
Child2.__init__(self)
39+
Child3.__init__(self)
40+
print("goes Grandson")
41+
42+
43+
if __name__=="__main__":
44+
Grandson()

0 commit comments

Comments
 (0)