Say I've got a metaclass and a class using it:
class Meta(type):def __call__(cls, *args):print "Meta: __call__ with", argsclass ProductClass(object):__metaclass__ = Metadef __init__(self, *args):print "ProductClass: __init__ with", argsp = ProductClass(1)
Output as follows:
Meta: __call__ with (1,)
Question:
Why isn't ProductClass.__init__
triggered...just because of Meta.__call__
?
UPDATE:
Now, I add __new__
for ProductClass:
class ProductClass(object):__metaclass__ = Metadef __new__(cls, *args):print "ProductClass: __new__ with", argsreturn super(ProductClass, cls).__new__(cls, *args)def __init__(self, *args):print "ProductClass: __init__ with", argsp = ProductClass(1)
Is it Meta.__call__
's responsibility to call ProductClass's __new__
and __init__
?