[Python-3000] Metaclasses in Py3K (original) (raw)
Talin talin at acm.org
Sat Dec 16 21:35:07 CET 2006
- Previous message: [Python-3000] Metaclasses in Py3K
- Next message: [Python-3000] Metaclasses in Py3K
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-3000] Metaclasses in Py3K
- Next message: [Python-3000] Metaclasses in Py3K
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]