Question OOP-CTOR-0065
HardWhat is the output of this code?
class R:
def __init__(self, n): self.n = n
def __enter__(self):
print("in", self.n, end=" ")
return self
def __exit__(self, et, ev, tb):
print("out", self.n, end=" ")
return True
with R(1), R(2):
raise ValueError
print("after")
- A.
in 1 in 2 out 1 out 2 after
- B.
in 1 out 1 in 2 out 2 after
- C.
Sign up free to see the answer and a step-by-step explanation.