I'm reading Pro Python 3. There in chapter 4 classes super() and its pitfalls is explained, with the final conclusion: "the only defense against such problems is an agreement among all classes involved to not change method signatures"
Sadly I'm not sure what that means. Wouldn't this kill the purpose of subclassing? Or how would be the "pythonic" way to do the following without changing the signature of __init__?:
class Geometry2d: def __init__(self, rotation_angle=0, destination=Point(0, 0)): # do something class Rectangle(Geometry2d): def __init__(self, width, height, rotation_angle=0, destination=Point(0, 0)): super().__init__(rotation_angle, destination) self.width = width self.height = height # ... As far as I understood, I changed the signature by adding two arguments (width and height) to the subclass Rectangle.__init__ and also changed the parameter order (arguments with default parameter at the end)?
super()uses a method without changing the signature). The "problem" mentioned is, that one needs a thourough understanding of method resolution order and how super() determines which attributes to use.