Newbie question: string replace

Alex Martelli aleaxit at yahoo.com
Fri Oct 28 22:56:37 EDT 2005


Mike Meyer <mwm at mired.org> wrote:

> "usgog at yahoo.com" <usgog at yahoo.com> writes:
> 
> > So how to overwrite the config file directly in script.py instead of
> > running script.py with two params?
> 
> Don't overwrite the file directly. Save a copy, then rename it. That

See module fileinput in the standard library, it does this for you
automatically when used in the right way -- much better than rolling
your own and having to debug it and maintain it forever!


Alex



More information about the Python-list mailing list