Ast tree and python code

Robert Brewer fumanchu at amor.org
Wed Mar 3 17:00:55 EST 2004


Yermat wrote:
> Does someone know how I can reverse an AST tree back into python code 
> with few modification ?
> What I want to do is to complete trees before writing them 
> back but in a 
> way not to far from the original code ? Especially, indentation, line 
> return, etc.
> 
> Of course, I could program it myself but if someone already done it...

I don't know of a full implementation (someone else might?) but I made a
start of it a week ago:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=mailman.219.1077
918544.8594.python-list%40python.org

Deriver.process() (inherited from Processor.process()) produces Python
statements from an AST node; it's only simple expressions at the
moment--no assignment, for example. Feel free to build on it.


Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org




More information about the Python-list mailing list