On Mon, Mar 30, 2015 at 12:03:47AM -0700, Andrew Barnert wrote:
On Mar 29, 2015, at 21:12, Ron Adam email@example.com wrote:
[snip stuff about dynamic scoping]
Raymond Hettinger's ChainMap (now also in the std lib) may possibly be used to emulate different scoping rules, including dynamic.
If you can build a function object with __globals__ set to a chained map, you may be able to accomplish most of what you are discussing.
By memory, __globals__ needs to be a dict, so you have to use a dict subclass, something like this:
class Context(ChainMap, dict): pass