Peter Mexbacher wrote:

> I have the following task:
> 
> 1) read in a file line by line
> 2) parse each line with a regular expression, and substitute certain 
> patterns
> 3) end result: the old file with the substituted stuff (and of course 
> everything which did not need substitution)
> 
> Do I have to write each line out to a new file, and then rename, or can
> I substitute "in place" - that the changes are incorporated in the old
> file automatically?

If you use the fileinput module with inplace=1 it will take care of this 
for you and even make a backup file if you like.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to