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

A metaclass overrides __call__. When you then instantiate a class that uses this metaclass, at what point does the metaclass's __call__ intervene relative to the instance's __new__ and __init__?

class Singleton(type): _i = {} def __call__(cls, *a, **k): if cls not in cls._i: cls._i[cls] = super().__call__(*a, **k) return cls._i[cls]