Can I avoid having to type out all my base class constructor parameters in my derived class? Ie, see the simple code below:
class Base():
def __init__(self, param1, param2, .... param10)
class Derived(Base):
def __init__(self, do I have to retype out all these params again?)
# also if the base params change I'll need to re-edit this constructor aswell
# is there an easier way?
My class inherits from a base class whose constructor has multiple parameters (~10). So I either need my class constructor to also have these params or maybe python has something where I don't have to physically type them out?
Heres my usecase:
class MyModel(peewee.Model):
ID = peewee.PrimaryKeyField()
name = peewee.CharField()
... many more fields
def onClick(self, e):
raise NotImplementedError("method 'MyModel::onClick' should be overridden!")
# MyModel instances can be created as so...
m = MyModel(name='bar', ...) # lots of properties
class FooModel(MyModel):
# Do I HAVE to explicitly state each parameter? Is there an easier way?
def __init__(self, ...):
MyModel.__init__(self, ...)
# initialise some properties
self.some_property = 1
self.another_property = 'foo'
def onClick(self, e):
# custom click handling
...
# I want to instantiate FooModel's the same way'
m = FooModel(name='bar', ...) # lots of properties