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