[Python-ideas] Simpler Customization of Class Creation, next round
Nick Coghlan
ncoghlan at gmail.com
Thu Apr 9 18:07:47 CEST 2015
On 6 April 2015 at 11:43, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> 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.
The main intended readability/maintainability benefit is from the
perspective of more clearly distinguishing the "customises subclass
initialisation" case from the "customises runtime behaviour of
subclasses" case.
A full custom metaclass doesn't provide any indication of the scope of
impact, while __init_subclass__ more clearly indicates that there's no
persistent effects on behaviour post-subclass creation.
> Another thing I'm unclear on is what will happen if a subclass were to
> define its own __init_subclass__?
Same thing that happens with any other class method - chaining to the
base class implementation would be in the hands of the subclass author
via super().
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list