Calling __init__ for all mixins

Martin Maney maney at pobox.com
Thu Aug 19 00:56:26 EDT 2004


Shalabh Chaturvedi <shalabh at cafepy.com> 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?  This is either brilliant or pure crack.  I'll have to ponder it
for a good long while.

> http://www.python.org/2.2.3/descrintro.html#cooperation

Brilliant.  Crack.  Brilliant.  Crack. ... Luminiferous Aether!

Was this chosen specifically to confuse anyone familiar with OO
terminology as used in other languages?  <wink>

> Any class wanting to participate in this technique must be new-style.

Which brings me back to the original motivation: any nice tricks for
doing this without NewSpeek classes?  Maybe in a year or so I can get
all the production machines upgraded; for now, I have to write to the
subset that works across 2.1, 2.2, and, mostly just as a nod to that
future so far, 2.3 (I frankly haven't the time to do much worrying
about 2.4 yet, and don't expect to any time soon.  It would be nice to
have only one or two machines to take care of and enough free time to
keep up to date with every release.)

-- 
Remember the refrain:  We always build on the past;
the past always tries to stop us.  Freedom is about stopping the past,
but we have lost that ideal.  -- Lawrence Lessig



More information about the Python-list mailing list