Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
from contextlib import contextmanager @contextmanager def managed_resource(): print("Setup") try: yield "resource" finally: print("Teardown") with managed_resource() as r: print(f"Using {r}") # Setup -> Using resource -> Teardown
Result
Open