Calling __init__ for all mixins

Michael Hudson mwh at
Thu Aug 19 19:39:42 CEST 2004

Martin Maney <maney at> writes:

> Shalabh Chaturvedi <shalabh at> wrote:
> > The new-style super mechanism might indeed solve your problem. In the 
> > snippet that you mention, super(NewStyleOnly, self).__init__() would 
> > only call A.__init__(). But A.__init__ should itself have a super call 
> > of the form:
> > def __init__(self):
> >     super(A, self).__init__()   # A's super call
> > Now *that* will call B.__init__(), which should itself have a super call 
> I will be dipped in shit.  So let me see... super(this_here_class,
> self) can and will resolve to a class that is not in any sane meaning
> of the word a super class of this_here_class, but rather a co-base of
> it?

No.  super(this_here_class, self) returns, well, a super() object that
when you look for an attribute on it acts a bit like `self.__class__'
but only looks in classes later than `this_here_class' in the MRO.

Don't worry too much if that didn't make sense, but it's probably a
good idea to get the thought that super() returns a class out of your

> This is either brilliant or pure crack.  I'll have to ponder it for
> a good long while.

It's brilliant :-)


  > Well, as an American citizen I hope that the EU tells the MPAA 
  > and RIAA to shove it where the Sun don't shine.
  Actually they already did. Only first they bent over and dropped
  their trousers.      -- Shmuel (Seymour J.) Metz & Toni Lassila, asr

More information about the Python-list mailing list