using super

Scott David Daniels Scott.Daniels at Acm.Org
Tue Jan 1 13:12:40 EST 2008


iu2 wrote:
> On Jan 1, 12:32 pm, Steven D'Aprano <st... at REMOVE-THIS-
> cybersource.com.au> wrote:
>> import read_my_mind_and_do_what_I_want
>> first. (Module expected in Python 9.7, due out in 2058.)
> 
> That's because it seems to you like some esoteric feature.
> To me it seems natural with OO.
And the language should not bend to the sense of "natural" of one with
a minor commitment to building that language.  If this really is a
great idea, implement it, put it out, support it and respond to the
rigors of real use.  You'll not convince me, but you needn't.  Too
many people want to go to a PEP (or even skip that step) once they have
an idea they think might be good.

The lesson I take from the histories of Ada and C++ are that "the
less in the language the better."  It is not enough that a language
be chock-a-block with good ideas; each idea in the language must be
compelling enough to counter-balance the mass that adding that idea
adds.

>> "Special cases aren't special enough to break the rules."
> 
> I thought about this mechanism each time I had to call a base class
> method.  Lisp has it, out of the box.  May be it's not so special...

We accept this seems natural to you.  You don't seem to understand why
others might not think so.  I fear this is the kind of thing that
separates programmers into two classes: the smart ones that can set up
the chains, and the others to whom you say "don't worry your pretty
little head about it; it all happens auto-magically."  Python is
remarkably free of such things, and I am loathe to give that up.
The value reduced auto-magic is that the users of the language
can learn smoothly, rather than climbing steep mountains of 
understanding.  Since you are relatively new to the language (I
presume so, since you left self out of several method definitions),
see how the language works on its terms first, before suggesting
how to make it more like some other language you like.

The explicit super call inside a method, and the disposition of
its results makes experimentation with different ways to use the
result tempting.  There is a temptation to play with the arguments
as well, that runs afoul of the vagaries of multiple inheritance,
that is the reason that I said "if they don't want to understand
super, then just explicitly name the superclass."

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list