I have a abstract base class that contains two attributes:
class Vehicle(metaclass=ABCMeta):
def __init__(self):
self._motor = self._build_motor()
self._wheels = self._build_wheels()
@property
def motor(self):
return self._motor
@abstractmethod
def _build_motor(self):
pass
@property
def wheels(self):
return self._wheels
@abstractmethod
def _build_wheels(self):
pass
Child class example :
class Moto(Vehicle):
def __init__(self, prop1, ...):
self.prop1 = prop1
# ...
def _build_motor(self):
# concrete implementation
def _build_wheels(self):
# concrete implementation
I would like the child methods _build_motor
and _build_wheels
to be called at init when I instanciate a child object. Is is possible?