-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinher.py
More file actions
72 lines (57 loc) · 1.23 KB
/
inher.py
File metadata and controls
72 lines (57 loc) · 1.23 KB
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
class A:
def __init__(self, x):
print(f"init A({x})")
self.x = x
def label(self):
print("A")
def f(self):
super().f()
print("f from A")
print(f"class name {self.__class__.__name__}")
x = self.__class__(3)
x.label()
@classmethod
def ff(cls):
# super().ff()
print("ff from A")
print(f"class name {cls.__name__}")
x = cls(3)
x.label()
class B:
def __init__(self, x):
print(f"init B({x})")
self.x = x
def label(self):
print("B")
def f(self):
# super().f()
print("f from B")
@classmethod
def ff(cls):
# super().ff()
print("ff from B")
print(f"class name {cls.__name__}")
x = cls(3)
x.label()
class C(A, B):
def __init__(self, x):
print(f"init C({x})")
self.x = x
def label(self):
print("C")
def f(self):
super().f()
print("f from C")
@classmethod
def ff(cls):
super().ff()
print("ff from C")
print(f"class name {cls.__name__}")
x = cls(3)
x.label()
return x
c = C(22)
c.f()
print("now ff")
x = c.ff()
print(type(x))