-- from "What's new in Python 2.2"
section 2.3 "Multiple Inheritance: The Diamond Rule"
"""
Multiple inheritance has also been made more useful
through changing the rules under which names are
resolved.
"""
Well, for a feature that was officially "introduced" in
version 2.2 it shows a remarkable lack of presence
(even in the CVS versions of 2.3)!!
// though, I could have missed something (an elephant in
// my backyard!), if so please point it out...
Description:
Actually, there is nothing wrong... the function in
question is just not changed since version 2.1.x, thus
we get the old style lookup table (Method resolution
order).
I'll try not to get too carried away.. here is an
example 'almost' literally taken from that same section
of the documentation mentioned above:
---cut---
class A:
def save(self):
return "I am 'A.save'"
class B(A):
pass
class C(A):
def save(self):
return "I am 'C.save'"
class D(B,C):
pass
print D().save()
---uncut---
Expected Results:
something printed EXACTLY like:
>>> I am 'C.save'
Actual Result:
//here is the part where I faint... :|
we get:
>>> I am 'A.save'
The results are identical for:
- Python 2.2
- Python 2.2.1
- Python 2.3 (CVS)
Thanks!!
|