[Python-Dev] Classes and Metaclasses in Smalltalk
Fredrik Lundh
fredrik@effbot.org
Wed, 2 May 2001 16:15:58 +0200
thomas wrote:
> > why not spell it out:
> >
> > self.__super__.foo(arg1, arg2)
> >
> > or
> >
> > self.super.foo(arg1, arg2)
> >
> > or
> >
> > super(self).foo(arg1, arg2)
>
> IMO we still need to specify the class, and there we are:
>
> super(self, MyClass).foo(arg1, arg2)
isn't that the same as self.__class__ ? in which case
super is something like:
import new
class super:
def __init__(self, instance):
self.instance = instance
def __getattr__(self, name):
for klass in self.instance.__class__.__bases__:
member = getattr(klass, name, None)
if member:
if callable(member):
return new.instancemethod(member, self.instance, klass)
return member
raise AttributeError(name)
(I'm even more confused than my pythonware.com colleague)
Cheers /F