[Python-3000] Metaclasses in Py3K
Talin
talin at acm.org
Sat Dec 16 21:35:07 CET 2006
Josiah Carlson wrote:
>> 2) What should the interface on the metaclass look like.
>>
>> The general idea is to have the metaclass create a mapping object which
>> is used as the 'locals' dictionary for the suite following the class
>> statement. There would be some special-named function of the metaclass,
>> such as '__metadict__', which would construct a new mapping object. I
>> haven't seen many alternative proposals to this.
>
> Proposal: don't make it a callable on the metaclass. It forces
> metaclasses into being classes, which I think is overly restrictive, or
> it forces people to do things like...
>
> def mymeta(...):
> ...
>
> mymeta.__metadict__ = mydict
I suppose you could make the new syntax require a callable that returns
a tuple of a dict and a finishing function, i.e.:
def mymeta( ... ):
def finish( dict ):
...
return finish, {}
class Foo( metaclass=mymeta ):
...
-- Talin
More information about the Python-3000
mailing list