using super

iu2 israelu at elbit.co.il
Tue Jan 1 08:52:33 EST 2008


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.


> "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...


> Since you have to call the superclass yourself, there's not that much
> difference between reminding people to call the superclass by hand, and
> reminding them to call some decorator.

Not necessarily. Once a class is declared with chains, its
deriveratives don't really need the decorator (Python will know about
it).
And even with a decorator, what if the class has 5 methods? That's one
decorator against 5 superclass calls.

> Admittedly, a decorator for the most common cases would be easier to use
> than super(), but I don't think it would make enough of a difference that
> it is worth changing Python's object model just to make it possible. As
>  ...
> And as others have pointed out, if you really want this desperately
> enough, you can create a metaclass to handle it.
>
That's right.



More information about the Python-list mailing list