[Python-3000] PEP 3124 - Overloading, Generic Functions, Interfaces, etc. (original) (raw)
Phillip J. Eby pje at telecommunity.com
Tue May 1 18:14:19 CEST 2007
- Previous message: [Python-3000] PEP 3124 - Overloading, Generic Functions, Interfaces, etc.
- Next message: [Python-3000] PEP 3124 - Overloading, Generic Functions, Interfaces, etc.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At 10:11 AM 5/1/2007 -0400, Jim Jewett wrote:
On 4/30/07, Phillip J. Eby <pje at telecommunity.com> wrote:
At 07:29 PM 4/30/2007 -0400, Jim Jewett wrote: >On 4/30/07, Phillip J. Eby <pje at telecommunity.com> 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 mymagicattribute ? 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
- Previous message: [Python-3000] PEP 3124 - Overloading, Generic Functions, Interfaces, etc.
- Next message: [Python-3000] PEP 3124 - Overloading, Generic Functions, Interfaces, etc.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]