Связь метакласса «__call__» и экземпляра «__init __»?

Скажем, у меня есть метакласс и класс, использующий его:

class Meta(type):
    def __call__(cls, *args):
        print "Meta: __call__ with", args

class ProductClass(object):
    __metaclass__ = Meta

    def __init__(self, *args):
        print "ProductClass: __init__ with", args

p = ProductClass(1)

Вывод следующий:

Meta: __call__ with (1,)

Вопрос:

Почему не запускается ли ProductClass .__ init __ ... только из-за Meta .__ call __ ?

ОБНОВЛЕНИЕ:

Теперь я добавляю __ новый __ для ProductClass :

class ProductClass(object):
    __metaclass__ = Meta

    def __new__(cls, *args):
        print "ProductClass: __new__ with", args
        return super(ProductClass, cls).__new__(cls, *args)

    def __init__(self, *args):
        print "ProductClass: __init__ with", args

p = ProductClass(1)

Обязан ли Meta .__ call __ вызвать ProductClass __ new __ и __ init __ ?

6
задан martineau 16 March 2018 в 15:32
поделиться