seek python parser

Paul Boddie paul at boddie.org.uk
Sun Aug 7 15:32:33 CEST 2005


I tend to use the compiler module:

http://docs.python.org/lib/compiler.html

With the output of the parsing functions I selectively inspect the AST
nodes using the named attributes listed in the documentation:

http://docs.python.org/lib/module-compiler.ast.html

For cases where one just needs to traverse the child nodes of an AST
node, the getChildNodes method is probably more helpful than the
getChildren method, which returns things like name strings and other
miscellaneous information mixed up with the list of nodes.

If you want a genuine XML DOM version of a Python AST, the following
project might provide you with a solution:

http://pysch.sourceforge.net/ast.html

See also:

http://uucode.com/texts/genxml/genxml.html

Paul




More information about the Python-list mailing list