From: "Guido van Rossum" <[EMAIL PROTECTED]> > class E(D): pass > > print E().f() > > This prints DDBCA which surely isn't right. > > Sounds like the classic bug in such attempts.
Yep - missing overridden methods tend to either do the above, or end up in infinite recursion. My bytecode hacking version doesn't suffer from these problems ... >>> class autosuper(object): ... __metaclass__ = _autosuper ... >>> class A(autosuper): ... def f(self): ... print 'A:', super ... >>> class B(A): ... def f(self): ... print 'B:', super ... super.f() ... >>> class C(A): ... def f(self): ... print 'C:', super ... super.f() ... >>> class D(B, C): ... pass ... >>> class E(D): ... def f(self): ... print 'E:', super ... super.f() ... >>> class F(E, A): ... pass ... >>> F().f() E: <super: <class 'E'>, <F object>> B: <super: <class 'B'>, <F object>> C: <super: <class 'C'>, <F object>> A: <super: <class 'A'>, <F object>> What I haven't worked out yet is if you should be able to do the following: class A(autosuper): def f(self): print 'A:', super class B(A): def f(self): def inner(): print 'B:', super super.f() inner() Should the call to inner() result in a call to A.f? Currently my bytecode version doesn't do this. I think this should be addressed in the PEP, as well as my proposal to have super(args) work as super.func(args) when called inside func. Tim Delaney _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com