replace string in a file

joep josef.pktd at gmail.com
Sat Mar 15 19:55:45 EDT 2008


you can also use standard module fileinput.input with ''inplace''
option which backs up original file automatically.

from python help for fileinput:

Optional in-place filtering: if the keyword argument inplace=1 is
passed to input() or to the FileInput constructor, the file is moved
to a backup file and standard output is directed to the input file (if
a file of the same name as the backup file already exists, it will be
replaced silently).




More information about the Python-list mailing list