Page MenuHomeSoftware Heritage
Paste P1351

(An Untitled Masterwork)
ActivePublic

Authored by vlorentz on Apr 26 2022, 11:54 AM.
$ cat example.py
import contextlib
@contextlib.contextmanager
def f():
print("start f")
yield
print("end f")
print("before")
with f():
print("inside")
print("after")
$ python3 example.py
before
start f
inside
end f
after