What does this program print?

from Context managers
Python 3.14 intermediate 3 min

What does this program print?

Python
class Gate:
    def __enter__(self):
        print("enter")
        return 7

    def __exit__(self, exc_type, exc_value, traceback):
        print("exit", exc_type.__name__)
        return exc_type is LookupError


with Gate() as value:
    print(value)
    raise LookupError("missing")
print("after")
Open in playground
Report an error