I have the following code:
class Vehicle:
def __init__(self, name=None, color='Red', make='Toyota'):
self._name = name
self._color = color
self._make = make
@property
def name(self):
if self._name is None:
return 'name is none'
return self._name
@name.setter
def name(self, value):
self._name=value
def getColor(self):
return self._color
def getMake(self):
return self._make
class Car(Vehicle):
def __init__(self, mode='Running', *args, **kwargs):
super().__init__(self, *args, **kwargs)
self._mode=mode
def getMode(self):
return self._mode
I want to initiate the name of the car, however neither of the following works. Is there a simple way to do it?
mycar=Car('Corolla')
mycar=Car(name='Corolla')
Do not pass self
into a super
bound __init__
class Car(Vehicle):
def __init__(self, mode='Running', *args, **kwargs):
super().__init__(*args, **kwargs)