PEP 422: Simpler customisation of class creation

Three questions: Would the new __initclass__ function be usable with actual full-blown metaclasses? The PEP says this:
If present on the created object, this new hook will be called by the class creation machinery after the __class__ reference has been initialised.
Given that statement, and this example: class A: def __initclass__(cls): # do stuff class B(A): pass am I correct that A's __initclass__ will not run when B is created? Where are we at with being ready for pronouncement? -- ~Ethan~

On 16 September 2013 00:19, Ethan Furman <ethan@stoneleaf.us> wrote:
Three questions:
Would the new __initclass__ function be usable with actual full-blown metaclasses?
Sure (as long as the metaclass in question called it at the appropriate time, which those inheriting from type would do automatically)).
The PEP says this:
If present on the created object, this new hook will be called by the class creation machinery after the __class__ reference has been initialised.
Given that statement, and this example:
class A: def __initclass__(cls): # do stuff
class B(A): pass
am I correct that A's __initclass__ will not run when B is created?
No, that would be pointless (since that's the way class decorators already behave). "present on the created object" means "hasattr(cls, '__initclass__') returns True.
Where are we at with being ready for pronouncement?
The PEP needs to be updated to incorporate the feedback from the last time I proposed it for inclusion. That's not going to happen for 3.4, I just forgot to mark it as Deferred - fixed now. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia
participants (2)
-
Ethan Furman
-
Nick Coghlan