Python's super() considered super!

John Nagle nagle at animats.com
Fri May 27 16:47:54 EDT 2011


On 5/27/2011 11:46 AM, Chris Angelico wrote:
> On Sat, May 28, 2011 at 4:31 AM, Ian Kelly<ian.g.kelly at gmail.com>  wrote:
>> It seems to me that the example of combining built-in dictionary
>> classes is naively optimistic.
>
> So... Can anyone offer a non-trivial example of multiple inheritance
> that *doesn't* have pitfalls?   From what I've seen, MI always seems > to require cooperation from 
the authors of all involved classes.

     Good point.

     Multiple inheritance is messy enough when the structure is just
a tree.  When the structure is allowed to be a directed acyclic
graph, the whole thing just gets too complicated.

     It doesn't even necessarily do what you want.  If, say, you
have two classes that need dictionaries, and were implemented
by inheriting from "dict", a class that imports both has one
"dict", not two - something that was not anticipated in the
design of the original classes.  That ought to be an error,
not a single "dict" shared by two unconnected classes.

     What causes this kind of mess is a determination not to
report anything as an error if it can be given some kind of
meaningful semantics, even if the semantics have marginal
value.  That's the kind of thinking which leads to

	[1,2] * 2

returning

	[1,2,1,2]



				John Nagle



More information about the Python-list mailing list