Creating new types and invoking super

Arnaud Delobelle arnodel at
Wed Jan 23 22:56:27 CET 2008

On Jan 23, 8:55 pm, "Guilherme Polo" <ggp... at> wrote:
> Hello,

> First I tried this:
> def init(func):
>     def _init(inst):
>         super(inst.__class__, inst).__init__()
>         func(inst)
>     return _init
> class A(object):
>     @init
>     def __init__(self): pass

This kind of approach can't work, you need to call super(A, obj).
super(type(obj), obj) is pointless, it defeats the whole purpose of
the mro!

The only way I can think of would be to create a metaclass, but I
don't think it's worth it.  super(A, obj).__init__() isn't that bad!


More information about the Python-list mailing list