
30 Mar
2015
30 Mar
'15
3:11 a.m.
On Mon, Mar 30, 2015 at 12:03:47AM -0700, Andrew Barnert wrote:
On Mar 29, 2015, at 21:12, Ron Adam ron3200@gmail.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.
http://code.activestate.com/recipes/577434-nested-contexts-a-chain-of-mappin...
http://code.activestate.com/recipes/305268-chained-map-lookups/
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
--
Steve