[Python-Dev] [Python-checkins] peps: PEP 422 rewrite to present an idea that a) isn't crazy and b) it turns out

Terry Reedy tjreedy at udel.edu
Wed Jun 6 20:30:35 CEST 2012



On 6/6/2012 7:40 AM, nick.coghlan wrote:
>    PEP 422 rewrite to present an idea that a) isn't crazy and
 > b) it turns out Thomas Heller proposed back in 2001

> +There is currently no corresponding mechanism in Python 3 that allows the
> +code executed in the class body to directly influence how the class object
> +is created. Instead, the class creation process is fully defined by the
> +class header, before the class body even begins executing.

This makes the problem for porting code much clearer.

 > +* If the metaclass hint refers to an instance of ``type``, then it is

/instance/subclass/? as in your class Metaclass(type) example in 
Alternatives?

 > +  considered as a candidate metaclass along with the metaclasses of a


> +Easier inheritance of definition time behaviour
> +-----------------------------------------------
> +
> +Understanding Python's metaclass system requires a deep understanding of
> +the type system and the class construction process. This is legitimately
> +seen as confusing, due to the need to keep multiple moving parts (the code,

/confusing/challenging/

The challenge is inherent in the topic. Confusion is not, but is a sign 
of poor explication that needs improvement.

> +the metaclass hint, the actual metaclass, the class object, instances of the
> +class object) clearly distinct in your mind.

Your clear separation of 'metaclass hint' from 'actual metaclass' and 
enumeration of the multiple parts has reduced confusion, at least for 
me. But it remains challenging.

> +Understanding the proposed class initialisation hook requires understanding
> +decorators and ordinary method inheritance, which is a much simpler prospect.

/much// (in my opinion) In other words, don't underplay the alternative 
challenge ;-).


tjr



More information about the Python-Dev mailing list