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

For a single `with` statement managing two context managers, what is the enter/exit order?

order = [] class CM: def __init__(self, n): self.n = n def __enter__(self): order.append(f"enter{self.n}"); return self def __exit__(self, *a): order.append(f"exit{self.n}"); return False with CM(1), CM(2): order.append("body") print(order)