[Python-3000] PEP 3115 chaining rules (was Re: pep 3124 plans)

Phillip J. Eby pje at telecommunity.com
Thu Aug 2 18:24:04 CEST 2007


At 07:46 AM 8/2/2007 -0700, Guido van Rossum wrote:
>On 8/1/07, Talin <talin at acm.org> wrote:
> > I think that in order to 'mix' metaclasses, each metaclass needs to get
> > a crack at the members as they are defined. The 'dict' object really
> > isn't important - what's important is to be able to overload the
> > creation of a class member.
> >
> > I can think of a couple ways to accomplish this.
> >
> > 1) The first, and most brute force idea is to pass to a metaclass's
> > __prepare__ statement an extra parameter containing the result of the
> > previous metaclass's __prepare__ method. This would allow the
> > __prepare__ statement to *wrap* the earlier metaclass's dict,
> > intercepting the insertion operations or passing them through as needed.
>
>I'm confused. The only way to mix metaclasses is by explicitly
>multiply inheriting them. So the normal "super" machinery should work,
>shouldn't it?

Yes.  As I said in the email Talin was replying to, it's sufficient 
to document the fact that a metaclass should call its super()'s 
__prepare__ and delegate operations to it; the additional stuff Talin 
is suggesting is unnecessary.

>  (Except for 'type' not defining __prepare__(), but that
>can be fixed.)

Yep. 



More information about the Python-3000 mailing list