I'm not too familiar with the use of abstract classes, so I'm trying to understand what is happening in some code I'm using at the moment.
In the code, I have a base dataset class, and some implementations of datasets inheriting from the main one, something like:
class dataset(metaclass=abc.ABCMeta):
def __init__():
# implementation of __init__
@abc.abstractmethod
def _some_method(self, ....):
return
class dataset_01(dataset):
def _some_method(self, ....):
# implementation of _some_method for dataset_01, overriding abstract method from base class
What I don't understand is, I was expecting to see a call for super().__init__()
in dataset_01:
class dataset_01(dataset):
def __init__(self, length):
super().__init__(...)
There's no such call, but when debugging the code, I noticed that I still end up in the constructor of dataset when creating an instance of dataset_01, in spite of the missing super.
Is the use of metaclass=abc.ABCMeta in the dataset class leading to some automatic method resolution, i.e. is it ensuring that the __init__
method of the base class is called anyway?
Or am I missing something else?