Open yeukhon opened 10 years ago
We know unparser.Unparser(new_nodes, sys.stdout)
will unparse ast nodes into source code and we could totally pipe it into a file.
Is there a different way?
Oh and using unparser.Unparser(new_nodes, sys.stdout)
we would need to add two things: adding Monitor
dictionary and monitor_on
function into the modified ast nodes.
Well we don't exactly HAVE to do that, but we will have to create a 2nd module which has the dictionary and the function, and import the modified module from the new source code. The pro of this approach is if we have more functions, we can easily do it without touching ast. The cons are another file and another import.
Idea is getting the modified ast nodes into an actual source file so we can just run from there.