KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to programmatically edit python source code. Basically I want to read a .py file, generate the AST , and then write back the modified python source code (i.e. another .py file). There are ways to parse/compile python source code using standard python modules, such as ast or compiler . However, I don't think any of them support ways to modify the source code (e.g. delete this function declaration) and then write back the modifying python source code. UPDATE: The reason I want to do this is I'd like to write a Mutation testing library for python, mostly by deleting statements / expressions, rerunning tests and seeing what breaks.
Tags (comma-separated)
Save Edits
Cancel