[Python-3000] PEP for Metaclasses in Python 3000 (original) (raw)

Phillip J. Eby pje at telecommunity.com
Tue Mar 13 04:42:06 CET 2007


At 09:32 PM 3/12/2007 -0600, Steven Bethard wrote:

On 3/12/07, Steven Bethard <steven.bethard at gmail.com> wrote: > the signature of the method called will be:: > prepare(name, args, kwargs) > not > prepare(name, *args, **kwargs) > right?

On 3/12/07, Guido van Rossum <guido at python.org> wrote: > I'm not sure anyone has thought much about it yet. I wonder > if the call shouldn't be made like this: > > prepare(name, bases, **kwargs) > > so that if you only expect certain specific keyword args you can > define it like this: > > def prepare(name, base, metaclass=X): ... Yeah, seems like **kwargs would be more useful in practice.

Really? Why? I can more easily see circumstances where you'd want to restrict the arguments. In the cases I have where I'd switch from a class decorator to a class keyword, I have a small set of decorators and would have an equally small set of keywords.

I think there might be a parallel argument for passing in the bases as *args instead of as a tuple. If you want to write a metaclass that expects exactly zero or one base classes, you could then write::

def prepare(name, **kwargs): def prepare(name, base, **kwargs):

Ugh. In principle, this isn't an issue if you can have keyword-only arguments, but I just don't like it. Maybe that's because in my mind, this is a parallel with the type() signature, and I don't see a reason for it to be different.



More information about the Python-3000 mailing list