[Python-3000] PEP for Metaclasses in Python 3000

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


Steven Bethard wrote:
> Initially, I was concerned that this would break the symmetry with the
> __metaclass__ signature::
> 
>     def __metaclass__(name, bases, bodydict):
>     def __prepare__(name, bases, kwargs):

Can someone clarify something here: Are the keywords going
to be passed to the prepare function only, or to both the
the prepare function and the metaclass?

If they're only passed to the prepare function, it means
that any metaclass that's interested in them will have to
implement a prepare function that creates some object to
hold onto them, even if it has no other need for a custom
namespace.

If they're passed to both, then the signatures become

   metaclass.__prepare__(name, bases, **kwargs)
   metaclass(name, bases, body, **kwargs)

BTW, I don't think I like the name "__prepare__" much
more than "__metacreate__". It seems just as wooly.
What's being prepared? How? What for?

--
Greg


More information about the Python-3000 mailing list