[Python-3000] PEP 3115 chaining rules (was Re: pep 3124 plans)
Guido van Rossum
guido at python.org
Thu Aug 2 18:48:27 CEST 2007
On 8/2/07, Phillip J. Eby <pje at telecommunity.com> wrote:
> 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.
Committed revision 56672.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list