super() doesn't get superclass

Hrvoje Niksic hniksic at xemacs.org
Thu Sep 20 04:31:46 EDT 2007


Ben Finney <bignose+hates-spam at benfinney.id.au> writes:

>> The definition of superclass is not the issue, the issue is
>> "superclass *of which class*"?  You expect super(A, self) to iterate
>> only over superclasses of A, even when self is an instance of a
>> subtype of A.
>
> Yes. Those are the specific parameters to the function call, so that
> *is* what I expect.

The specific parameters are a type and an instance.  Those same
parameters can and do allow for an implementation that accesses
supertypes of type(self).  That is in fact more logical; otherwise one
could simply iterate over A.__bases__ and we wouldn't need an
elaborate 'super' construct.

Not iterating only over A's superclasses is the entire *point* of
super.  The only deficiency of super I see in this thread is
incomplete documentation.



More information about the Python-list mailing list