2008/1/23, Arnaud Delobelle <[EMAIL PROTECTED]>: > On Jan 23, 8:55 pm, "Guilherme Polo" <[EMAIL PROTECTED]> wrote: > > Hello, > > Hi > [...] > > 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! >
Yeh, as shown in the next examples in the previous email. Using a decorator for that doesn't sound useful at all, was just trying something different ;) I will stick to the no-decorator option. > 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! > Metaclass doesn't apply here because metaclass is related to class-construction. This is related to instance initialization, and I'm creating the types as the user asks. > -- > Arnaud > > -- > http://mail.python.org/mailman/listinfo/python-list > -- -- Guilherme H. Polo Goncalves -- http://mail.python.org/mailman/listinfo/python-list