[Python-Dev] PEP 422: Simpler customisation of class creation (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Sun Sep 15 16:40:48 CEST 2013
- Previous message: [Python-Dev] PEP 422: Simpler customisation of class creation
- Next message: [Python-Dev] Relative path in co_filename for zipped modules
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 16 September 2013 00:19, Ethan Furman <ethan at 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 at gmail.com | Brisbane, Australia
- Previous message: [Python-Dev] PEP 422: Simpler customisation of class creation
- Next message: [Python-Dev] Relative path in co_filename for zipped modules
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]