[Python-ideas] A way out of Meta-hell (was: A (meta)class algebra) (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Sun Feb 22 15:54:45 CET 2015
- Previous message: [Python-ideas] A way out of Meta-hell (was: A (meta)class algebra)
- Next message: [Python-ideas] A way out of Meta-hell (was: A (meta)class algebra)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 23 February 2015 at 00:25, Nick Coghlan <ncoghlan at gmail.com> wrote:
On 22 Feb 2015 21:36, "Martin Teichmann" <lkb.teichmann at gmail.com> wrote:
Another detail: I think it could be useful if the additional **kwargs to the class statement were forwarded to (sub)classinit. No, that kind of variable signature makes cooperative multiple inheritance a nightmare to implement. The PEP 422 hook is deliberately designed to act like an inheritable class decorator that gets set from within the body of the class definition. It's not intended to provide the full power and flexibility offered by a metaclass - it's designed to let folks that understand class decorators and class methods combine the two concepts to define a class decorator that gets called implicitly for both the current class and all subclasses.
Ah, thank you: this discussion kicked a new naming idea lose in my brain, so I just pushed an update to PEP 422 that renames the proposed init_class hook to be called autodecorate instead.
"It's an implicitly invoked class decorator that gets inherited by subclasses" is really the best way to conceive of the proposed hook, so having "init" as part of the name not only made it hard to remember whether the hook was init_class or class_init, it also got people thinking along completely the wrong lines.
By contrast, the "auto" in "autodecorate" only makes sense as a prefix, and the inclusion of the word "decorate" in the name means it should be far more effective at triggering the reader's "class decorator" mental model rather than their "class initialisation" one.
Regards, Nick.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-ideas] A way out of Meta-hell (was: A (meta)class algebra)
- Next message: [Python-ideas] A way out of Meta-hell (was: A (meta)class algebra)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]