super(...).__init__() vs Base.__init__(self)

Jan Niklas Fingerle usenet-2004 at lithe.de
Sun Feb 12 15:39:43 EST 2006


Tony Nelson <*firstname*nlsnews at georgea*lastname*.com> wrote:
> In article <43eba7f7$0$507$9b4e6d93 at newsread4.arcor-online.net>,
>  Jan Niklas Fingerle <usenet-2004 at lithe.de> wrote:
> 
> > ...Super is a good tool to use, when dealing with
> > diamond shape inheritance. In any other case I would use the direct
> > calls to the base classes. In fact, i've yet to find a non-textbook-case
> > where I really need diamond shape inheritance. ...
> 
> As long as you don't use multiple inheritance with new-style classes, 
> you'll be fine.

OK, I should have written: "... diamond shape inheritance where the base
class's methods have to be called cooperatively ..."

In other words: In almost every real world example of diamond shape
inheritance where the base class is "only" object we don't have a
problem, because you don't have to call object's __init__, yet it causes
no harm if you call it twice - and __init__ is the *the* method you most
commonly would use "super()" for.

So, yes, "no multiple inheritance" is sufficient, but not nessecary to
live happily without ever using "super()".

Nothing against super where it's appropiate. But don't optimize for
("real") diamond shape inheritance, before you really need it...

Cheers,
  --Jan Niklas



More information about the Python-list mailing list