Consider the following class:
class Car():
def __init__(self, model):
self.model = model
If I wanted to define specific models, I could do something like this:
class FordGT(Car):
model = "Ford GT"
def __init__(self):
Car.__init__(self,self.model)
In that way, I could create a large amount of different car models. The only problem with doing this though, is that for every car model, I am repeating the init function.
def __init__(self):
Car.__init__(self,self.model)
Code repetition to me is always a sign of bad code. How could I fix this? Is it possible to pass init arguments to the parent without using an init on a child?