On Tue, Mar 17, 2015 at 9:55 AM, Martin Teichmann firstname.lastname@example.org wrote:
recently I posted PEP 487, a simpler customization of class creation. For newcomers: I propose the introduction of a __init_subclass__ classmethod which initializes subclasses of a class, simplifying what metaclasses can already do.
From what I've read, PEP 487 is adding functionality to classes that
is already provided by metaclasses, but metaclasses still provide the identical capability. Basically, what is the difference between the following?
class Meta(type): def __init__(cls, ...): ...
class X(metaclass=Meta): ...
class Base: def __init_subclass__(cls, ...): ...
class X(Base): ...
The only difference I see is relative to metaclass conflcts. You still have to define an extra type (Meta or Base) to get the effect. Furthermore, there would now be second (but indistinct) way of initializing a subclass, making the "meta" class situation even murkier.
If the only benefit is the mitigation of metaclass conflicts then perhaps such conflicts should be addressed directly and we should not add __init_subclass__. From other threads it sounds like we should be able to solve metaclass conflicts one way or another.
Another thing I'm unclear on is what will happen if a subclass were to define its own __init_subclass__?