[Python-Dev] Possible context managers in stdlib

Raymond Hettinger python at rcn.com
Fri Jul 8 23:26:19 CEST 2005


> > I compiled a list of some possible new context managers that could
be
> > 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
> right),
> > but with context managers, there's certainly room to add some. Of
> course,
> > my list is excessive, it's only some ideas I got by flying over the
> stdlib
> > docs.

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.



Raymond


More information about the Python-Dev mailing list