[Python-Dev] Classes and Metaclasses in Smalltalk (original) (raw)

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