Popular recipes tagged "ast" but not "function"http://code.activestate.com/recipes/tags/ast-function/2015-02-05T20:18:08-08:00ActiveState Code RecipesPython AST to XML (Python) 2015-02-05T20:18:08-08:00Robert Stewarthttp://code.activestate.com/recipes/users/4191612/http://code.activestate.com/recipes/579019-python-ast-to-xml/ <p style="color: grey"> Python recipe 579019 by <a href="/recipes/users/4191612/">Robert Stewart</a> (<a href="/recipes/tags/ast/">ast</a>, <a href="/recipes/tags/xml/">xml</a>). </p> <p>Convert Python ASTs to XML files for reading in other languages.</p> Python AST to XML (Python) 2013-08-07T00:42:35-07:00Ryan Gonzalezhttp://code.activestate.com/recipes/users/4187447/http://code.activestate.com/recipes/578625-python-ast-to-xml/ <p style="color: grey"> Python recipe 578625 by <a href="/recipes/users/4187447/">Ryan Gonzalez</a> (<a href="/recipes/tags/ast/">ast</a>, <a href="/recipes/tags/xml/">xml</a>). </p> <p>Converts Python ASTs to XML files for reading in other languages.</p> Code to source and back (Python) 2012-12-01T08:59:49-08:00Oren Tiroshhttp://code.activestate.com/recipes/users/2033964/http://code.activestate.com/recipes/578353-code-to-source-and-back/ <p style="color: grey"> Python recipe 578353 by <a href="/recipes/users/2033964/">Oren Tirosh</a> (<a href="/recipes/tags/ast/">ast</a>, <a href="/recipes/tags/decompile/">decompile</a>, <a href="/recipes/tags/recompile/">recompile</a>, <a href="/recipes/tags/uncompile/">uncompile</a>). </p> <p>Converts a code object to a source code snippet and back: <code>c == recompile(*uncompile(c))</code></p> <p>This is useful, for example, if you want to apply an AST transformation to the code.</p> Nested 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>