ExitStack in Python
Over the years, I’ve used Python’s contextlib.ExitStack in a few interesting ways. The official ExitStack documentation advertises it as a way to manage multiple context managers and has a couple of examples of how to leverage it. However, neither in the docs nor in GitHub code search could I find examples of some of the maybe unusual ways I’ve used it in the past. So, I thought I’d document them here. ...