I have some Code (for ev3dev):
class Motor(object):
def __init__(self, portName):
self.base = "/sys/class/tacho-motor/motor"
self.number = self.getMotorNumberWithSpecificPortName(portName)
self.name = self.base + str(self.number) + "/"
self.setDefaultValues()
def __del__(self):
self.callReset()
(...)
class TurnMotor(Motor):
def __init__(self):
super(TurnMotor, self).__init__("outA")
def __del__(self):
super(TurnMotor, self).__del__()
The goal is to define multiple motor classes like TurnMotor
in this example who inherit from Motor
and automatical __init__
with their specific port. They also should call the parents __del__
method on destruction to reset the motor.
I know that in this case I have to define a __init__
method for the subclass to initiate with the port I want but would the parents __del__
method still be called from the subclass if I leave out the definition for __del__
in the subclass?
Would this in general be possible for __init__
too?