beza1e1 wrote: > Is it possible compiler.parse a statement, then change and then > execute/resolve it?
This should work: >>> from compiler.pycodegen import ModuleCodeGenerator >>> from compiler.misc import set_filename >>> from compiler import parse >>> >>> tree = parse('foo = 42') >>> set_filename('<foo>', tree) >>> code = ModuleCodeGenerator(tree).getCode() >>> exec code >>> foo 42 Also, if you need to turn an AST back into Python code, I have some ugly code for doing that: <http://ecritters.biz/asttosource.py>. -- http://mail.python.org/mailman/listinfo/python-list