[Python-3000] PEP for Metaclasses in Python 3000

Georg Brandl g.brandl at gmx.net
Tue Mar 13 19:56:41 CET 2007


BJörn Lindqvist schrieb:
> On 3/13/07, Guido van Rossum <guido at python.org> wrote:
>> > > I find this rather cool looking:
>> > >
>> > >   class C(implements=(I1, I2)): ...
>>
>> Me too. :-)
> 
> But... What does it do? PEP says:
> 
> In the new model, the syntax for specifying a metaclass is via a
> keyword argument in the list of base classes:
> 
>       class Foo(base1, base2, metaclass=mymeta):
>         ...
> 
> Additional keywords will also be allowed here, and will be passed to
> the metaclass, as in the following example:
> 
>       class Foo(base1, base2, metaclass=mymeta, private=True):
>         ...
> 
> Who is the receiver of the implements keyword argument in your
> example? Should it not be class class C(metaclass = SomethingHere,
> implements = (I1, I2))?

If Foo inherits from another class whose metaclass already accepts
"implements", it should work.

I can't see how "class C(implements=(I1, I2))" would work though,
without a hook to set a default metaclass.

Georg



More information about the Python-3000 mailing list