Skip to content

Instantly share code, notes, and snippets.

@wchargin
Created Mar 30, 2021
Embed
What would you like to do?
calling `cm().__enter__()` on a `@contextlib.contextmanager`
import contextlib
@contextlib.contextmanager
def cm():
print("fst")
yield
print("snd")
cm().__enter__()
$ python3 -V
Python 3.8.7
$ python3 /tmp/test.py
fst
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment