On 7 August 2011 17:02, Mike Graham <mikegraham@gmail.com> wrote:
On Sun, Aug 7, 2011 at 10:50 AM, dag.odenhall@gmail.com <dag.odenhall@gmail.com> wrote:
How about adding the context manager protocol to collections.ChainMap, as an in-place combination of new_child() and parents()? The effect would simulate lexical scope using the with-statement.
Trivial to do customly but always nice when builtin or stdlib types support the context manager protocol. :)
I don't understand the utility of such a thing. Can you post a use case or two to make it clearer to people like me?
To be quite honest I'm not perfectly sure myself; it just seemed like such a natural context manager that I got curious if it was just overlooked or if I was missing something. If it turns out it would make sense it might be good to realize it early before the 3.3 release?