[Python-Dev] PEP487: Simpler customization of class creation
Nick Coghlan
ncoghlan at gmail.com
Tue Jul 19 10:34:07 EDT 2016
On 19 July 2016 at 16:41, Neil Girdhar <mistersheik at gmail.com> wrote:
> Yes, I see what you're saying. However, I don't understand why
> __init_subclass__ (defined on some class C) cannot be used to implement the
> checks required by @abstractmethod instead of doing it in ABCMeta. This
> would prevent metaclass conflicts since you could use @abstractmethod with
> any metaclass or no metaclass at all provided you inherit from C.
ABCMeta also changes how __isinstance__ and __issubclass__ work and
adds additional methods (like register()), so enabling the use of
@abstractmethod without otherwise making the type an ABC would be very
confusing behaviour that we wouldn't enable by default.
But yes, this change does make it possible to write a mixin class that
implements the "@abstractmethod instances must all be overridden to
allow instances to to be created" logic from ABCMeta without otherwise
turning the class into an ABC instance.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-Dev
mailing list