Edit Python code programmatically
Guilherme Polo
ggpolo at gmail.com
Sat Feb 9 06:47:22 EST 2008
2008/2/9, Alex <noname9968 at gmail.com>:
> Which library could you recommend to perform simple editing of Python
> code (from Python program)? For example, open *.py file, find specific
> function definition, add another function call inside, find existing
> call and change parameter value, etc.
>
You are after inspect, it is included with python.
> What I'm trying to implement isn't a real visual programming tool, but
> some code-generation is necessary. For now I think I can generate Python
> syntax manually (like any text file), but it can become more complicated
> in future (like partially implementing code-generation library), plus
> there'll always be possibility of corrupting files and losing data (or
> having to recover valid Python syntax manually) due to coding mistake.
>
Generating code like this is always dangerous. Maybe you could
generate some other kind of file, then use some library or build one,
to operator over this file.
> Thanks
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
-- Guilherme H. Polo Goncalves
More information about the Python-list
mailing list