Edit Python code programmatically

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sat Feb 9 07:01:45 EST 2008


On Sat, 09 Feb 2008 14:38:29 +0300, Alex wrote:

> Which library could you recommend to perform simple editing of Python
> code (from Python program)? 

I'm not even sure such a library exists.


> For example, open *.py file, find specific
> function definition, add another function call inside, find existing
> call and change parameter value, etc.

Why do you want to do that? I'm not sure what you're trying to 
accomplish. Code refactoring? I imagine that's probably best done with 
your text editor: at best, your editor will have dedicated refactoring 
tools, and at worst, it will have global search and replace.



-- 
Steven



More information about the Python-list mailing list