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

Guido van Rossum guido at python.org
Thu Aug 2 16:46:32 CEST 2007


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? (Except for 'type' not defining __prepare__(), but that
can be fixed.)

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list