Let's consider the following dummy example:
class A:
def __init__(self, a):
self.a = a
self.backup_a = a
def reset_a(self):
self.a = self.backup_a
print ('Stop touching my stuff!')
class B(A):
def __init__(self, a, b):
super().__init__(a)
self.b = b
var = A(2)
var.reset_a()
var = B(2, 4)
var.f()
To add a method to B which uses the method reset_a from A, boh syntax with super(). or self. works. Which one is more correct and why?
class B(A):
def __init__(self, a, b):
super().__init__(a)
self.b = b
def f(self):
self.reset_a()
OR
class B(A):
def __init__(self, a, b):
super().__init__(a)
self.b = b
def f(self):
super().reset_a()