On 4/30/07, Phillip J. Eby <[EMAIL PROTECTED]> wrote: > At 07:29 PM 4/30/2007 -0400, Jim Jewett wrote: > >On 4/30/07, Phillip J. Eby <[EMAIL PROTECTED]> wrote:
> >>PEP 3115, however, requires that a class' metaclass be determined > >>*before* the class body has executed, making it impossible to use this > >>technique for class decoration any more. > >It doesn't say what that metaclass has to do, though. > >Is there any reason the metaclass couldn't delegate differently > >depending on the value of __my_magic_attribute__ ? > Sure -- that's what I suggested in the "super(), class decorators, and PEP > 3115" thread, but Guido voted -1 on adding such a magic attribute to PEP > 3115. I don't think we're understanding each other. Why couldn't you use a suitably fleshed-out version of: class _ConditionalMetaclass(type): def __init__(cls, name, bases, dct): super(_ConditionalMetaclass, cls).__init__(name, bases, dct) hooks = [(k, v) for (k, v) in dct.items() if k.startswith("_afterhook_")] for k, v in hooks: cls = AfterHooksRegistry[k](cls, v) -jJ _______________________________________________ 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