super - is (should) it (be) a reserved word?
Grant Edwards
ge at nowhere.none
Mon Oct 9 10:25:29 EDT 2000
In article <mailman.971064623.25775.python-list at python.org>, Michal Wallace wrote:
>> Alex Martelli wrote:
>> >
>> > self.__class__.__bases__[0] satisfies this request, I think.
>>
>> Not when there is more than one level of inheritance
>> involved. The class you want to find the base class
>> of isn't the class of self, it's the class where the
>> currently executing method was defined, and there's
>> currently nothing in Python that keeps track of that.
Excellent point. I should have thought of that.
>Why do you need that? Calling a method of a class
>climbs the hierarchy for you, all the way up to where
>the method was first defined or last overridden.
The example I most often run into is in an __init__ method
where I want to initialize the features my subclass is adding
and then pass control and the remaining arguments on up to the
__init__ method one layer up. The "super" that I want access
to is the parent of the class containing the reference to
"super", not the parent of the class of "self".
--
Grant Edwards grante Yow! Yow!
at
visi.com
More information about the Python-list
mailing list