[Python-Dev] Classes and Metaclasses in Smalltalk

M.-A. Lemburg mal@lemburg.com
Wed, 02 May 2001 16:02:41 +0200


Guido van Rossum wrote:
> 
> > This doesn't work in Python since Python has multiple inheritence,
> > e.g. super in
> >
> > class A(B,C):
> >       def foo(self):
> >               super.foo()
> >
> > is ambiguous.
> 
> I'm not sure what you mean.  The search is totally well-defined: first
> search B for a foo method, then search C.

I thought you were talking about an abstract super class which is
how Java uses this term. 

Rereading some of the posts, I think you are indeed referring to
the method which foo overrides -- this is what I call basemethod
(since it is implemented in one of the base classes).
 
> > I'd rather suggest adding a function for finding the basemethod
> > of a method. This is probably the most common task in this context.
> 
> I've never heard of the concept of basemethod, but if I may venture a
> guess, it would be the same definition as I give above.

The basemethod can be defined as the first method of the same name
found in the inheritence tree using the standard Python lookup 
strategy (left-right, depth first) when continuing the lookup search
at the node in the inheritence tree which defines the method querying
the basemethod.

In other words: you let Python continue the search for the method
as if it hadn't found the occurrance calling the bsaemethod()
API. Hmm, still not clear enough... better let Tim jump in here
(we've had a discussion about basemethod() some months or years
ago). Tim ?

Note that there are many ways of defining what a basemethod
is, due to the ambiguities that are caused by multiple inheritence
(e.g. the same base class may appear in different branches of the
inheritence tree).

-- 
Marc-Andre Lemburg
______________________________________________________________________
Company & Consulting:                           http://www.egenix.com/
Python Software:                        http://www.lemburg.com/python/