RE: [Python-Dev] Re: super() harmful?
Guido van Rossum wrote:
and the cumbersome way in which you have to invoke super.
Given Python's dynamic nature I couldn't think of a way to make it less cumbersome. I see you tried (see below) and couldn't either. At this point I tend to say "put up or shut up."
Well, there's my autosuper recipe you've seen before: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286195 which does basically what Philip descibes ...
import autosuper
class A (autosuper.autosuper): ... def test (self, a): ... print 'A.test: %s' % (a,) ... class B (A): ... def test (self, a): ... print 'B.test: %s' % (a,) ... self.super(a + 1) ... class C (A): ... def test (self, a): ... print 'C.test: %s' % (a,) ... self.super.test(a + 1) ... class D (B, C): ... def test (self, a): ... print 'D.test: %s' % (a,) ... self.super(a + 1) ... D().test(1) D.test: 1 B.test: 2 C.test: 3 A.test: 4
It uses sys._getframe() of course ... Tim Delaney
On Jan 6, 2005, at 5:45 PM, Delaney, Timothy C (Timothy) wrote:
Well, there's my autosuper recipe you've seen before: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286195
which does basically what Philip descibes ...
You missed the most important part of the example -- the automatic argument passing through unknowing methods. James
participants (2)
-
Delaney, Timothy C (Timothy) -
James Y Knight