I would like to give a daughter class some extra attributes without having to explicitly call a new method. So is there a way of giving the inherited class an __init__
__init__
Just call a designated method from the parent's init, if it exists:
class initialclass(): def __init__(self): self.attr1 = 'one' self.attr2 = 'two' if hasattr(self, 'init_subclass'): self.init_subclass() class inheritedclass(initialclass): def init_subclass(self): self.attr3 = 'three'