[Python-3000] Metaclasses in Python 3000: Draft 2 (original) (raw)
Phillip J. Eby pje at telecommunity.com
Thu Mar 15 17:19:35 CET 2007
- Previous message: [Python-3000] Metaclasses in Python 3000: Draft 2
- Next message: [Python-3000] Metaclasses in Python 3000: Draft 2
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At 12:13 PM 3/15/2007 +1300, Greg Ewing wrote:
Phillip J. Eby wrote:
> So the subset required is determined entirely by what the class body > (and metaclass new) require. Perhaps the PEP should say something to the effect that get, set and delete need to be implemented in order to support all the things the class body might want to do, but a metaclass can omit them if it wants to restrict what can be done in the class body. > So the metaclass' new > is going to need to read out the contents of the pseudo-dict somehow, or > generate alternative contents. Maybe the PEP should specify a protocol that the pseudo-dict must provide for doing this, such as an iteritems() method (or whatever the Py3k equivalent is).
That's not necessary; the metaclass instance call (or class new) should be responsible for passing a real dictionary to type.new, if it in fact wants to create a type object all. Remember, metaclasses need not be types, nor to create types. For that matter, it isn't necessarily the case that the metaclass will directly map the dictionary "contents" into a dictionary at all. There may be renaming of keys, creation of new keys, code generation, and who-knows-what-else. So, having a protocol for transforming the suite locals into a type dictionary would be unnecessarily restrictive.
- Previous message: [Python-3000] Metaclasses in Python 3000: Draft 2
- Next message: [Python-3000] Metaclasses in Python 3000: Draft 2
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]