-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path005_multyple_inheritance.py
More file actions
49 lines (41 loc) · 909 Bytes
/
005_multyple_inheritance.py
File metadata and controls
49 lines (41 loc) · 909 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
class Person:
def __init__(self, name, surname):
self.name = name
self.surname = surname
def say_hi(self):
print("Hi")
class Employee:
def say_hello(self):
print("Hello")
class Manager(Person, Employee):
pass
manager = Manager("Michal", "Hucko")
manager.say_hi()
manager.say_hello()
# The diamond problem pre super class atributy
class A:
name = "A"
class B(A):
name = "B"
def __init__(self, b):
self.b = b
class C(A):
name = "C"
def __init__(self, c):
self.c = c
class D(C,B):
name = "D"
def get_super(self):
print(super().name)
d = D("text")
d.get_super()
# print(d.b)
print(d.c)
# Solution is the inheritance liearization applied as method resolution order
# # mro method
# print(D.mro())
# print(list.mro())
# print(int.mro())
# print(bool.mro())
# print(float.mro())
# print(tuple.mro())