Python AST -> source code

R

Ricardo Santos

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.

Thanks

Ricardo Santos
 
L

Lonnie Princehouse

If you _do_ wind up writing a pretty printing AST visitor, post it
somewhere! I've searched around for something like this before with
no luck.
 
F

Fidel Viegas

Can someone point me to an open source solution? I don't want to have
to implement a "pretty printing" AST visitor myself.

Looks like that is what you will have to do, cause I don't know of any
open source solution to this.

All the best

Fidel.
 
J

John J. Lee

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 know there's currently an AST branch of Python, containing
widely-spread changes throughout the core Python code. What the goal
of these changes are, though, I don't know. Google tells me the
changes are still pre-alpha, which is why they still haven't been
merged into CVS HEAD.

Maybe it's relevant, I don't know...


John
 
M

Michael Hudson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top