I am trying to call the return values of a function within a class (Second) to another class(First) using super(). The class - Second is below class First. The code is as follows
class First(Second):
def __init__(self):
super().__init__()
self.num1 = 1
# add num
def add_nums(self):
print(self.num1 + self.set_num2())
class Second:
def __init__(self):
self.num2 = 2
# Set num2
def set_num2(self):
return self.num2
a = First()
a.add_nums()
This actually works. However, if I add another class - Third below Second and call it in the class First, it doesn't work.
For instance, the following code doesn't work
class First(Second,Third):
def __init__(self):
super().__init__()
self.num1 = 1
# add num
def add_nums(self):
print(self.num1 + self.set_num2() + self.set_num3())
class Second:
def __init__(self):
self.num2 = 2
# Set num
def set_num2(self):
return self.num2
class Third:
def __init__(self):
self.num3 = 3
def set_num3(self):
return self.num3
a = First()
a.add_nums()