I want to define a 'with' command that makes entries in dictionary available within the local scope, and stores new local variables into that dictionary. The original scope should be restored on exit, and called functions should not see anything special. Can I do this?
my_dict = dict(a=1, b=2) with MyScope(my_dict): print "A", a, "B", b x = 3 print my_dict["x"] print x # FAIL, unbound -- http://mail.python.org/mailman/listinfo/python-list