[Python-ideas] A way out of Meta-hell (was: A (meta)class algebra) (original) (raw)

Martin Teichmann lkb.teichmann at gmail.com
Sun Feb 22 12:35:44 CET 2015


Backportability is at best a nice-to-have when it comes to designing changes to core semantics, and it certainly doesn't justify additional design complexity.

Speaking of which, I just checked out Daniel's code which was proposed as an implementation of PEP 422. To my astonishment, it does not do what I (and others) had expected, it does not add new functionality to type.new or type.init, instead the new machinery is in builtins.build_class. This has weird consequences, e.g. if you create a new class by writing type("Spam", (SpamBase,) {}), class_init will not be called. I consider this a really unexpected and not desirable behavior. Sure, types.new_class has been modified accordingly, but still.

So I think that the current version of PEP 422 unnecessarily adds some unexpected complexity, all of which could be easily avoided with my init_subclass (or subclass_init? whatever) approach.

Another detail: I think it could be useful if the additional **kwargs to the class statement were forwarded to (sub)class_init.

Greetings

Martin

PS there has been some discussion about politeness on this list. I apologize for having been harsh. I hope we can all get back to discussing python and how to improve it! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150222/0f43eb68/attachment.html>



More information about the Python-ideas mailing list