because of the pop_all() operation (which moves all of the registeredYep. You can also do some pretty interesting things with ExitStack
operations to a *new* ExitStack instance).
I wrote up a few of the motivating use cases as examples and recipes
in the 3.3 docs:
http://docs.python.org/3/library/contextlib#examples-and-recipes
I hope to see more interesting uses over time as more people explore
the possibilities of a dynamic tool for composing context managers
without needing to worry about the messy details of unwinding them
correctly (ExitStack.__exit__ is by far the most complicated aspect of
the implementation).
Cheers,
Nick.