Top-rated recipes tagged "chained"http://code.activestate.com/recipes/tags/chained/top/2010-10-25T02:13:37-07:00ActiveState Code RecipesNested contexts -- a chain of mapping objects (Python) 2010-10-25T02:13:37-07:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/577434-nested-contexts-a-chain-of-mapping-objects/ <p style="color: grey"> Python recipe 577434 by <a href="/recipes/users/178123/">Raymond Hettinger</a> (<a href="/recipes/tags/ast/">ast</a>, <a href="/recipes/tags/chained/">chained</a>, <a href="/recipes/tags/compiler/">compiler</a>, <a href="/recipes/tags/dictionary/">dictionary</a>, <a href="/recipes/tags/inheritance/">inheritance</a>, <a href="/recipes/tags/nested/">nested</a>, <a href="/recipes/tags/nonlocal/">nonlocal</a>, <a href="/recipes/tags/scopes/">scopes</a>, <a href="/recipes/tags/xml/">xml</a>). Revision 2. </p> <p>Easy to use chain of dictionaries for crafting nested scopes or for a tree of scopes. Useful for analyzing AST nodes, XML nodes or other structures with multiple scopes. Can emulate various chaining styles including static/lexical scoping, dynamic scoping and Python's own globals(), locals(), nested scopes, and writeable nonlocals. Can also model Python's inheritance chains: instance dictionary, class dictionary, and base classes.</p>