[Python-Dev] Submitting PEP 422 (Simple class initialization hook) for pronouncement
Nick Coghlan
ncoghlan at gmail.com
Sun Feb 10 14:52:33 CET 2013
More information about the Python-Dev mailing list
Sun Feb 10 14:52:33 CET 2013
- Previous message: [Python-Dev] Submitting PEP 422 (Simple class initialization hook) for pronouncement
- Next message: [Python-Dev] Submitting PEP 422 (Simple class initialization hook) for pronouncement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sun, Feb 10, 2013 at 11:33 PM, Simon Cross <hodgestar+pythondev at gmail.com> wrote: > On Sun, Feb 10, 2013 at 2:32 PM, Nick Coghlan <ncoghlan at gmail.com> wrote: >> For those that don't recall the original discussion, the proposal is >> to add a new __init_class__ hook, invoked after the class object is >> created, but before the class decorators are applied. This provides a >> simple approach to inherited post-creation modification of classes, >> without the need for a custom metaclass. > > Couldn't one just write a metaclass that calls __init_class__ for you? And, indeed, that's what Zope did more than 10 years ago. The problem is that you're now locked in to that metaclass - metaclass conflicts become a permanent risk. You also can't *add* a metaclass to public classes, the risk of introducing metaclass conflicts means that such a change is always backwards incompatible. Adding __init_class__ is fine though, because that's no higher risk than adding a __new__ or __init__ method (it's actually lower risk, since the signature is always consistent). Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-Dev] Submitting PEP 422 (Simple class initialization hook) for pronouncement
- Next message: [Python-Dev] Submitting PEP 422 (Simple class initialization hook) for pronouncement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list