[Python-3000] PEP for Metaclasses in Python 3000
Greg Ewing
greg.ewing at canterbury.ac.nz
Sat Mar 10 08:31:32 CET 2007
Talin wrote:
> class Foo(base1, base2, metaclass=mymeta):
> ...
-1 on this syntax, I think it's ugly.
Alternative proposals:
class Foo(base1, base2) as MyMeta:
...
or
class Foo(base1, base2) = MyMeta:
...
> class Foo(base1, base2, metaclass=mymeta, private=True):
> ...
class Foo(base1, base2) as MyMeta(private=True):
...
or
class Foo(base1, base2) = MyMeta(private=True):
...
> This attribute is a method named __metacreate__
Very bad choice of name -- it's not creating a meta-anything,
and gives no clue what it is creating.
> It would be possible to leave the existing __metaclass__ syntax in
> place. Alternatively, it would not be too difficult to modify the
> syntax rules of the Py3K translation tool to convert from the old to
> the new syntax.
The existing syntax actually has some advantages, e.g.
you can do things like
class Foo:
class __metaclass__:
# Real class methods defined here
which I think is rather elegant, so I'm not sure I'd
like the new syntax to completely replace the old one.
--
Greg
More information about the Python-3000
mailing list