Перейти к основному содержимому
🔒 Режим превью. Первые 15 уроков Foundations — бесплатные; этот — Pro. Запусти 7-дневный trial чтобы открыть редактор, AI-подсказки и остальной курс. Нужна карта, отмена в Dashboard в любой момент.Начать 7-дневный trial →
← КурсыSenior Deep-DivesМодуль 1 · Внутренние механизмы параллелизма и асинхронностиМетаклассыpredict5 / 161
+100 XP
Задание🌐 shown in EN
📝 **Task:** Predict the exact output. \`Meta.__new__\` prints \`meta_new:<name>\` as each class is built. \`Base.__init_subclass__\` prints \`init_sub:<name>\` and appends to \`registry\`. Two questions: (1) Does \`init_sub\` fire when \`Base\` itself is created? (2) Inside \`Meta.__new__\` — does \`print\` run before or after \`super().__new__\` builds the class? 📋 Implement the function above. Tests run automatically. 💡 **Hint:** Re-read the theory if you get stuck.
Предскажи вывод

Прочти код внимательно

class Meta(type):
    def __new__(mcs, name, bases, ns):
        print(f"meta_new:{name}")
        return super().__new__(mcs, name, bases, ns)


class Base(metaclass=Meta):
    registry = []
    def __init_subclass__(cls, **kwargs):
        print(f"init_sub:{cls.__name__}")
        Base.registry.append(cls.__name__)


class A(Base):
    pass


class B(Base):
    pass


print(Base.registry)

Что выведет программа? Напиши здесь: