Raymond Hettinger wrote:
I compiled a list of some possible new context managers that could
added to the stdlib. Introducing a new feature should IMO also show usage of it in the distribution itself. That wasn't done with decorators (a decorators module is compiled at the moment, if I'm
but with context managers, there's certainly room to add some. Of
my list is excessive, it's only some ideas I got by flying over the
The PEP contains plenty of examples. If you're really feeling the need, add something to the demo directory.
For the most part, the applications need to work themselves out over time through wikis, individual patch submissions, ASPN recipes, third-party apps, etc.
The natural evolution of best practices tends to get thwarted by prematurely using the standard library to cast a particular solution in stone.
This doesn't preclude individual patches such as a context manager for decimal.Context objects. Each proposal should be considered on its own merits rather than as a part of an overall effort to ram a bunch of these into the standard library. Over time, plenty of these will sprout-up.
As with decorators? Sure, plenty have sprouted up, but delivering them one release after the feature itself (if the decorators module makes it into 2.5) seems a little bit like lagging behind -- especially when good and useful examples exist.
Of course, not all of these in my list are good ideas to implement.