Right, so I have to create this inheritance hierarchy for a school project, so ignoring certain redundancies (like how Square really doesn't need 2 parents), I've come across a strange way Python handles super calls.
When initializing a square in the following code, it calls its super, which executes the Rectangle's initialization method. This makes sense. The rectangle then calls its super, which should go to the Parallelogram's initialization method; however, after some debugging, I've found that when it makes its super call, it is actually calling the Rhombus's initialization method. Can someone explain what is happening here and, if possible, a way to implement this properly without explicitly using class names?
Relevant code is below.
class Parallelogram:
def __init__(self, base, side, theta):
self.base = base
self.side = side
self.theta = theta
class Rectangle(Parallelogram):
def __init__(self, base, side):
super(Rectangle, self).__init__(base, side, 90)
class Rhombus(Parallelogram):
def __init__(self, side, theta):
super(Rhombus, self).__init__(side, side, theta)
class Square(Rectangle, Rhombus):
def __init__(self, side):
super(Square, self).__init__(side, side)