Read and Write the same file

JonathanB doulos05 at gmail.com
Tue May 1 20:04:08 EDT 2007


> Well the most straight forward approach is to read data from the file
> into memory. Let the user make any changes. Then save the data back to
> the file, overwriting the oringinal copy. Now, this only really works
> if you're dealing with small files.
>
> Regardless though, you never really need to have a file open for both
> reading and writing. Since they occur (so it sounds) at distinct times
> during your program flow, just open it twice: the first to read, the
> second to write.
>
> Ian

That makes sense. The largest document is  >10K, so it shouldn't be a
problem.




More information about the Python-list mailing list