[Python-3000] Metaclasses in Py3K

Josiah Carlson jcarlson at uci.edu
Sat Dec 9 18:27:04 CET 2006

"Calvin Spealman" <ironfroggy at gmail.com> wrote:
> The obvious problem with a metaclass specific syntax is that it doesnt
> allow for other things. Adding keyword options to class declarations
> means you could do things beyond just metaclasses, such as interfaces,
> if that happens.

Right, but as is being discussed in another thread, perhaps one doesn't
want to say, "this implements the full sequence interface", but instead
"this implements these portions of the sequence interface".

The proposal that I sent to Talin can be summed up as...

Use keywords as suggested by Guido, but give them a different name.

    class FooClass(X, Y, type=FooType):

One can then expand the keyword argument to include support for the
dictionary-like object to be used during class body execution.

    class FooClass(X, Y, dict=FooDict):

Then we don't have the issue with 'need to instantiate the metaclass
before we can get the special dict from it'.  In the other thread, they
don't really bring up "implements the full interface", but that could be
handled by class decorators in a similar fashion to what I proposed
there, or even something like the above as...

    class FooClass(X, Y, implements=sequence):

It is getting a bit unwieldy...

    class FooClass(X, Y, type=FooType, dict=FooDict,

But I think that any syntax that supports all three of the currently
proposed "wouldn't it be nice if" can get that way.

 - Josiah

More information about the Python-3000 mailing list