[Python-3000] Removing 'self' from method definitions

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Apr 17 03:41:56 CEST 2006


Guido van Rossum wrote:
> On 4/16/06, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:

> > In the case of __init__
> > methods, most of the time it simply doesn't work,
> > because different __init__ methods rarely have the
> > same signature.
> 
> How does that prevent you from using super()? (Hint: it doesn't. :-)

It's okay as long as you know which __init__ method
the super() is going to call, so you know its signature.
But if you know that, there's no need to use super() --
just call it directly.

The use case for super() is where you have a chain of
methods that are sufficiently compatible that you don't
need to know or care which one you're calling next.
That's not usually the case with __init__ methods.

The other possible reason for using super() is so
you don't have to write the name of the base class
into all your inherited method calls. But that's a
separate issue that would be better addressed by a
different mechanism, rather than conflating the
two in super().

--
Greg


More information about the Python-3000 mailing list