[Python-3000] Fixing super anyone?

Tim Delaney tcdelaney at optusnet.com.au
Wed Apr 25 03:20:54 CEST 2007

From: "Tim Delaney" <tcdelaney at optusnet.com.au>

> I've been off sick from work for over a week - I've been following this
> discussion, but now I think I've got something which matches all the
> criteria we've been discussing, so I've changed my subscription address
> temporarily to my home one.
> It involves bytecode hacking for now, as well as a metaclass. The code is
> attached. It's based partially off my 'self.super' recipe, but doesn't 
> need
> to use sys._getframe().

Oh - some output ...

>>> 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):
...     def f(self):
...         print 'D:', super
...         super.f()
>>> D().f()
D: <super: <class 'D'>, <D object>>
B: <super: <class 'B'>, <D object>>
C: <super: <class 'C'>, <D object>>
A: <super: <class 'A'>, <D object>>

Tim Delaney 

More information about the Python-3000 mailing list