Lets say I have the following
class cls1():
def __init__(self, num):
self.num = num
def square(self):
return self.num*self.num
Then I create a subclass.
class cls2(cls1):
k1 = super().square(self)
Basically I want to use the square function of the parent class. But this is giving an error RuntimeError: super(): no arguments
If I directly use the square function as following
class cls2(cls1):
k1 = square(self)
This gives an error NameError: name 'square' is not defined
.
I don't understand what is the problem. This is what inheritance means right? cls2 should automatically take all the data and procedural attributes from cls1. So why is this not working?