[Python-Dev] Possible context managers in stdlib

Barry Warsaw barry at python.org
Fri Jul 8 23:19:28 CEST 2005


On Fri, 2005-07-08 at 16:24, Reinhold Birkenfeld wrote:

> I compiled a list of some possible new context managers that could be
> added to the stdlib.

I agree with Brett and Phillip that a few well-chosen context managers
would make sense in the stdlib both for convenience and for example
purposes.  Keep the list short and sweet.  Also, I'd like to see some
higher-level cm's in the mix, perhaps implementing concepts like Java's
synchronized (perhaps even being named 'with synchronization').

Thinking about the types of code I write over and over again, I think I
disagree (slightly) with James about the global state thing.  While I
agree that 'with redirected_stdio' isn't too useful in the face of
print>>, I very often have to write try/finally protections around
temporary settings of the cwd, the umask, and other global process
values.  I'd love to see cm's for those constructs in the stdlib.

-Barry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-dev/attachments/20050708/841cd6d3/attachment.pgp


More information about the Python-Dev mailing list