super - is (should) it (be) a reserved word?

Alex Martelli aleaxit at yahoo.com
Mon Oct 9 16:26:20 EDT 2000


"John J. Lee" <phrxy at csv.warwick.ac.uk> wrote in message
news:Pine.SOL.4.21.0010091832560.3611-100000 at mimosa.csv.warwick.ac.uk...
    [snip]
> > not called from a method, etc.  And a mixin approach,
> > such as I suggested, might still artificially synthesize
> > (and presumably cache) an object of that class to be
> > returned - if, that is, super() can be written.
>
> A what approach?

mixin, aka mix-in: a class designed to be (multiply) inherited
from for the purpose of 'mixing' some functionality into the
inheriting-class; a popular style in some languages which
support multiple inheritance, and very handy for certain
tasks.


> > Trying to put this in practice, the first difficulty
> > is that one can easily get to the code-object (via the
> > traceback and frame objects), but not from that back
> > to the method-object (and thus via im_class to the
> > class whose 'super' is actually of interest).  Am I
> > having a spot of localized blindness, or is it in fact
> > a problem...?
> [...]
>
> No idea!

Oh well, I currently worked-around the blind-spot
(assuming it's one) by a simple linear search through
the linear chain of leftmost base-classes for a
method of the given name whose code-object equals
the caller's.  The depth of the inheritance will most
likely be small enough that a linear search's performance
[O(N) on that depth] should not be a big problem.

See my other recent post on this thread (although the
alternative, simpler suggestion of setting self.__super
at the start of each class's block may well be better
in this case -- its simplicity surely argues for it!).


Alex






More information about the Python-list mailing list