[Python-Dev] multiple inheritance -- what I meant

Paul F. Dubois paul@pfdubois.com
Sat, 5 May 2001 18:10:37 -0700


When I suggested a modification to the inheritance clause,

class X (Y rename a as b, c as d, Z rename foo as bar):

someone suggested this was the same as

class X (Y, Z):
    b = Y.a
    d = Y.c
    bar = Z.foo

I meant two things by my suggestion:

1. I meant that Y.a would never be found when searching for X.a.

In particular, if Z.a exists, and a is not explicity defined in X, X.a is
Z.a.

2. More philosophically, rather than being a consequence of the language
like the second method is, the proposed syntax is intended to be a clear
message to someone reading the class about how the inherited names are being
handled. Compare the effort required of a reader to understand these two.
(If you think the second one is easier, you probably attended Spam III.)

If you can rename in this way there are no problems with multiple
inheritance.

To be complete you should probably also allow

Y undefine x, ...

which simply makes Y.x unavailable from X.