Bruno Desthuilliers <[EMAIL PROTECTED]> writes: > Ben Finney a écrit : > > Evan Klitzke <[EMAIL PROTECTED]> writes: > >> On Tue, 2007-09-18 at 14:15 +1000, Ben Finney wrote: > >>> [the 'super' function] doesn't return the superclass, it returns > >>> the next class in the MRO, whether that's a superclass or not. > >> The next class in the MRO _is_ a superclass. > > > > [demonstration that the next class in the MRO is not necessarily a > > superclass] > > > > You seem to be saying that now suddenly D *is* a superclass of > > A. > > I don't see such an assertion in Evan's answer. Chapter and verse > ???
I've trimmed the quoting to make it clearer. Evan is claiming that "the next class in the MRO _is_ a superclass", apparently by his definition or some other that I've not seen. I've shown a fairly simple multiple-inheritance hierarchy where the next class in the MRO is not an ancestor of the subject class, but is instead a class that merely shares a common ancestor. Either "superclass of A" is equivalent to "ancestor class of A", or it's not. I maintain that many programmers will expect that it is, but Evan's assertion says otherwise. It can't be both. > > That's certainly not what users will think of when they think > > "superclass" though. > > If a class X is in the MRO of call Y, then X is a superclass of Y. That goes completely against what Alex Martelli told me, which was that "superclass" can be thought of as synonymous with "ancestor". > I agree that the documentation for super is somewhat misleading (and > obviously wrong), Well, that's the first time someone has acknowledged that in this thread, so I guess this is something. > but it still *give access to* (at least one of) the superclass(es). Only if you allow "some class somewhere in the inheritance tree, even one this class never inherited from directly or indirectly" to be in the definition of "superclass". I'm arguing that what people mean by "superclass" is "a direct or indirect ancestor class", and it's highly misleading to imply that by the function name what that's not what the function does. > >>> After reading the rest of the article, I'm amazed that 'super' > >>> as currently implemented is in Python at all. > > If you have a better solution for handling multiple inheritence, > please share with us. My concern is to at least not *directly mislead* the programmer through a badly-named function. If 'super' can invoke a non-superclass — if instead it gets "the next class in the MRO" — then this is at the least badly-named. > FWIW, after all the articles I've read explaining why Python is > badly designed, badly implemented, and totally flawed, I do wonder > why this language exists at all !-) In most of those arguments I'm firmly on the side of the Python designers. Not on this one. > > I don't want to break the inheritance chain. I want the > > superclass, > > A soon as you have either multiple inheritence and/or an inheritence > tree with depth > 1, there's no such thing as "the" superclass. wrt/ > your exemple, object, A, B, C and D are *all* superclasses of E. Yes, they are. But my example was not "get the superclass of E", but "get the superclass of A". The *only* ancestor of 'A' in the example is 'object', so I expect "superclass of A" to *always* get 'object'. But that's not what happens! Instead, it *sometimes* gets 'object', and *sometimes* gets 'D' — depending on who has inherited from a class that isn't even 'A'! That's what makes 'super' definitely misnamed, and practically unusable. > The next class in the MRO is (usually and AFAICT) the most direct > superclass. Demonstrably not, in the examples given in <URL:http://fuhm.org/super-harmful/>. > I wouldn't use such an extreme word as 'madness', but I totally agree > that this should be corrected. Care to submit a doc patch ? I don't understand what practical uses 'super' is intended for (only that they don't seem to match any of my needs), so the only replacement I would come up with would not be constructive. -- \ "A computer once beat me at chess, but it was no match for me | `\ at kick boxing." -- Emo Philips | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list