[Tutor] writing changes to a file

Craig Hagerman craig@osa.att.ne.jp
Wed, 9 Feb 2000 20:30:36 +0900


Hope this isn't too elementary: I need some guidance in how to open and
existing file, write some changes to it and then then close it. So far I
have been creating a new file for the changed version like this:

input = open('file_one','r')
output = open('file_two','w')

However,  I don't always need to have two files. I only want to change all
instances of "x" to "y", or perhaps add some new lines to the existing
file, and then save the new version. Is it possible to open a file to write
some changes to it in one go?


Craig Hagerman