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

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