Is inheritance broken?
Jonathan Claggett
jcc.ugm at ix.netcom.com
Wed Mar 28 12:30:26 EST 2001
Hello, I'm new to python and, while learning about inheritance, I've run
into what seems to be broken behavior with multiple inheritance. Here is the
code:
>>> class parallelogram:
... def angle(self): return "variable"
... def side(self): return "variable"
...
>>> class rhombus(parallelogram):
... def side(self): return "same"
...
>>> class rectangle(parallelogram):
... def angle(self): return "90 degrees"
...
>>> class square(rhombus, rectangle):
... pass
...
>>> test_square = square()
>>> print test_square.angle()
variable
>>>
It looks like the inherited angle method from rectangle is being ignored.
Isn't this wrong? Or am I just missing something.
More information about the Python-list
mailing list