[Python-3000] Metaclass syntax?

Guido van Rossum guido at python.org
Mon May 1 16:36:43 CEST 2006


On 5/1/06, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Bill Birch wrote:
>
> >    class[KindsOfTrees]  TheLarch(deciduous):
> >          pass
>
> I'd prefer not to put anything between 'class' and
> the name being defined. Maybe
>
>    class TheLarch(deciduous) [KindsOfTrees]:
>      ...

This has usually been solved by creating a non-meta class whose only
purpose is to introduce the new metaclass. You'd write

class TheLarch(KindsOfTrees, deciduous): ...

and the metaclass would be called KindsOfTreesMeta.

(Of course you could come up with a different naming convention.)

--
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list