Python Tip #293 (of 365): Write context managers with contextlib.contextmanager....

@treyhunner@mastodon.social

Python Tip #293 (of 365):

Write context managers with contextlib.contextmanager.

Instead of making a class with __enter__ and __exit__ methods, we can make a context manager out of a function:

๐Ÿงต (1/4)

#Python #DailyPythonTip