Popular recipes tagged "ast" but not "nested"http://code.activestate.com/recipes/tags/ast-nested/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> Parse call function for Py2.6 and Py2.7 (Python) 2009-02-28T20:13:15-08:00Jervis Whitleyhttp://code.activestate.com/recipes/users/4169341/http://code.activestate.com/recipes/576671-parse-call-function-for-py26-and-py27/ <p style="color: grey"> Python recipe 576671 by <a href="/recipes/users/4169341/">Jervis Whitley</a> (<a href="/recipes/tags/ast/">ast</a>, <a href="/recipes/tags/call/">call</a>, <a href="/recipes/tags/function/">function</a>, <a href="/recipes/tags/namedtuple/">namedtuple</a>, <a href="/recipes/tags/nodevisitor/">nodevisitor</a>, <a href="/recipes/tags/parsing/">parsing</a>). Revision 14. </p> <p>In some cases it may be desirable to parse the string expression "f1(*args)" and return some of the key features of the represented function-like call. </p> <p>This recipe returns the key features in the form of a namedtuple. </p> <p>e.g. (for the above)</p> <pre class="prettyprint"><code>&gt;&gt;&gt; explain("f1(*args)") [ Call(func='f1', starargs='args') ] </code></pre> <p>The recipe will return a list of such namedtuples for <code>"f1(*args)\nf2(*args)"</code> Note that while the passed string expression must evaluate to valid python syntax, names needn't be declared in current scope.</p>