[Python-3000] PEP for Metaclasses in Python 3000

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Mar 13 10:31:35 CET 2007


Guido van Rossum wrote:
> 
> On 3/10/07, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
 >
> >   class Foo:
> >     class __metaclass__:
>
> Personally, I find code that does this completely unreadable

The reason I'd be a little disappointed to lose this is that
it provides a concise way of defining genuine class methods
(as opposed to the odd beasts created by classmethod()).
Sometimes you need them, e.g. for __xxx__ methods, or if you
want inheritance to work properly.

Having said that, I can't remember whether I've ever actually
used this, and I probably wouldn't miss it all that much.

> I find this rather cool looking:
> 
>   class C(implements=(I1, I2)): ...

I'm a bit worried that class headers are going to become
rather cluttered if we start putting all sorts of stuff
in there.

E.g. are you intending to put __slots__ there? It makes
sense, but it could lead to some rather long and
unwieldy class headers.

--
Greg


More information about the Python-3000 mailing list