[Python-3000] PEP for Metaclasses in Python 3000

Talin talin at acm.org
Sat Mar 10 20:27:13 CET 2007


Josiah Carlson wrote:
> There are two semantics that I would be happy with.  Either force
> metaclasses to have a .metadict() or equivalent method (or a callable
> attribute in the case of arbitrary callables), or even allow
> __metaclass__ to be a tuple:
> 
>     class foo(...):
>         __metaclass__ = mytype, newdict
> 
> Newdict needs to be callable, and if you want to pass certain
> semantic-altering arguments, make newdict a factory can call it directly...
> 
>     class foo(...):
>         __metaclass__ = mytype, newdict(no_dupes=True)
> 
> One wouldn't even need any of the default arguments only stuff to make
> the two 'newdict' examples above use the same callable.

I strongly feel that this makes *using* metaclasses way too complex. A 
person wanting to create a C struct or a database record should simply 
have to say "metaclass=cstruct" - they shouldn't have to declare a bunch 
of individual pieces, all of which have to match with each other. 
There's no utility in being able to "mix n' match" metaclasses and dicts.

In any case, we're just going over old ground here.

-- Talin




More information about the Python-3000 mailing list