super().method()
and ClassName.method()
do the same thing but when to use super().method()
vs self.method()
?
Based on my understanding, one will use super().method()
when super method is called from the same method whereas will use self.method()
when calling from other methods of the child class.
class Animal():
def run(self):
print('running')
def walk(self):
print('walking')
class Cat(Animal):
def run(self):
super().run()
def walk_fast(self):
self.walk() ---> super().walk() also works but any reason using one over the other ?
c = Cat()
c.run()
c.walk_fast()