Python AST -> source code

Michael Hudson mwh at python.net
Tue Jul 20 13:50:54 EDT 2004


dpgkru at email.com (Ricardo Santos) writes:

> Hi,
> 
> I have a Python AST, which I have modified slightly (but still a valid
> Python AST). How do I go back to its source code representation?
> 
> source code -> AST   (POSSIBLE)
> AST -> source code   (????????)
> 
> Can someone point me to an open source solution? I don't want to have
> to implement a "pretty printing" AST visitor myself.

I'm fairly sure no such thing exists.  If you end up doing it, do let
us know :-)

I doubt it's amazingly hard, but probably a bit tedious.

Cheers,
mwh

-- 
  > It might get my attention if you'd spin around in your chair,
  > spoke in tongues, and puked jets of green goblin goo.
  I can arrange for this.  ;-)            -- Barry Warsaw & Fred Drake



More information about the Python-list mailing list