Recompile AST?

François Pinard pinard at
Thu Nov 10 22:38:36 CET 2005

[chrisspen at]

> Is it possible to recompile the AST generated by compiler.parse, back 
> into code or an executable code object?  My aim here is to allow 
> a script to manipulate Python code as elements within a list. However, 
> it doesn't look like the module has any native methods designed to do 
> this.

Pynits does something like this for pretty-printing Python statements, 
from within Vim.  I did not touch this project for a while, yet I still 
intend to revisit it in a few weeks or months (for an actual need).  You 
may peek at:

François Pinard

More information about the Python-list mailing list