At 10:11 AM 5/1/2007 -0400, Jim Jewett wrote:
>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.
Yup, and we're still not now. :) Or at least, I don't understand what the
code below does, or more precisely, why it's different from just having a
__decorators__ list containing direct callbacks. The extra indirection of
having an "after hooks" registry and separate attributes doesn't appear to
add anything, although if it turned out you really needed it, you could
just add a callback to __decorators__ that did it.
> 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
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com