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

Steven Bethard steven.bethard at gmail.com
Tue Mar 13 04:32:30 CET 2007


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. Initially, I was concerned that this would break the symmetry with the metaclass signature::

def __metaclass__(name, bases, bodydict):
def __prepare__(name, bases, kwargs):

But then I realized that there's really no need for any symmetry here -- they're getting passed two different things (kwargs != bodydict) and they're serving two pretty different purposes.

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):

STeVe

I'm not in-sane. Indeed, I am so far out of sane that you appear a tiny blip on the distant coast of sanity. --- Bucky Katt, Get Fuzzy



More information about the Python-3000 mailing list