post
Python idioms I reach for daily, part 2: context managers beyond `with open()`
Part 2 of a 3-post series. Context managers earn their keep when you have a resource that must be set up and torn down — and `with open()` is barely scratching the surface. Five patterns: timing, transactions, async, ExitStack, and supressing exceptions.