[Python-Dev] Classes and Metaclasses in Smalltalk
Donald Beaudry
Donald Beaudry <donb@abinitio.com>
Wed, 02 May 2001 11:37:39 -0400
"Fredrik Lundh" <fredrik@effbot.org> wrote,
> 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:
super is a lexically scoped concept. You cant ask the instance for it
since it's value is different depending on in which it is needed Just
as:
class foo(bar):
def __repr__(self):
return self.__class__.__repr__(self)
would get you into an infinite loop, while:
class foo(bar):
def __repr__(self):
return bar.__repr__(self)
wont. Now, dont go thinking that
class foo(bar):
def __repr__(self):
return self.__class__.__base__[0].__repr__(self)
will do you any good either ;) Because it wont!
--
Donald Beaudry Ab Initio Software Corp.
201 Spring Street
donb@init.com Lexington, MA 02421
...So much code, so little time...