Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumPythoncustom context managersSingle-choice MCQ

A class-based context manager's __exit__ returns the value shown. An exception is raised inside the `with` block. What happens?

class CM: def __enter__(self): return self def __exit__(self, exc_type, exc, tb): return 1 with CM(): raise RuntimeError("x") print("reached")