Re: read and write the same text file

2013-03-09 Thread Steven D'Aprano
On Sat, 09 Mar 2013 10:47:34 -0500, Roy Smith wrote: > In article , > iMath wrote: >> def text_process(file): >> with open(file,'r') as f: >> text = f.read() >> with open(file,'w') as f: >> f.write(replace_pattern.sub('',text)) > > At a minimum, you need to close the fi

Re: read and write the same text file

2013-03-09 Thread Roy Smith
In article , iMath wrote: > read and write the same text file > Open a text file ,read the content ,then make some change on it ,then write > it back to the file ,now the modified text should only has the modified > content but not the initial content ,so can we implement this by only set th