Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardPythonmetaclasses and __new__Single-choice MCQ

A class is created with the statement below. At which point does CPython invoke the metaclass's __prepare__, and what is its role in class body execution?

class Meta(type): @classmethod def __prepare__(mcs, name, bases, **kwds): return {'injected': 99} class A(metaclass=Meta): pass print(A.injected) # 99 print('injected' in A.__dict__) # True