[issue1734] no effect if metaclass modifies dict

Amaury Forgeot d'Arc report at bugs.python.org
Fri Jan 4 09:39:42 CET 2008


Amaury Forgeot d'Arc added the comment:

When designing a metaclass, you should override __new__, not __init__:

class MetaNode(type):
   def __new__(cls, name, bases, cdict):
       cdict['z'] = name
       return type.__new__(cls, name, bases, cdict)

class Node(object):
   __metaclass__ = MetaNode

----------
nosy: +amaury.forgeotdarc
resolution:  -> invalid
status: open -> closed

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1734>
__________________________________


More information about the Python-bugs-list mailing list