-
Notifications
You must be signed in to change notification settings - Fork 6
/
038.Test_PyClass.py
112 lines (83 loc) · 1.08 KB
/
038.Test_PyClass.py
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
class A:
def __init__(self):
print('begin')
self.a1()
self.a2()
self.a3()
def a1(self):
print('a1')
print('a1')
def a2(self):
print('a2')
def a3(self):
print('a3')
a = A()
# begin
# a1
# a1
# a2
# a3
class B(A):
def __init__(self):
super(B, self).__init__()
def a2(self):
print('a2')
print('a2')
b = B()
# begin
# a1
# a1
# a2
# a2
# a3
class C(A):
def __init__(self):
super(C, self).__init__()
def a3(self):
print('a3')
print('a3')
c = C()
# begin
# a1
# a1
# a2
# a3
# a3
class D(B, C):
def __init__(self):
super(D, self).__init__()
d = D()
# begin
# a1
# a1
# a2
# a2
# a3
# a3
class E(A):
def __init__(self):
super(E, self).__init__()
self.x = 1
def a2(self):
print('a2')
print('a2')
self.x = 2
def a3(self):
print('a3')
print('a3')
self.x = 3
e = E()
print(e.x)
e.a2()
print(e.x)
# begin
# a1
# a1
# a2
# a2
# a3
# a3
# 1
# a2
# a2
# 2