In metaclass, when to use __new__ vs. __init__?
Matthew Wilson
matt at tplus1.com
Mon May 12 12:10:21 EDT 2008
I have been experimenting with metaclasses lately. It seems possible to
define a metaclass by either subclassing type and then either redefining
__init__ or __new__.
Here's the signature for __init__:
def __init__(cls, name, bases, d):
and here's __new__:
def __new__(meta, classname, bases, d):
Every metaclass I have found monkeys with d, which is available in both
methods. So when is it better to use one vs the other?
Thanks for the help.
Matt
--
Programming, life in Cleveland, growing vegetables, other stuff.
http://blog.tplus1.com
More information about the Python-list
mailing list