Reading file issue

loial jldunn2000 at gmail.com
Mon Jan 28 07:03:54 EST 2013


Thanks for confirming my sanity



On Monday, 28 January 2013 11:57:43 UTC, Chris Angelico wrote:
> On Mon, Jan 28, 2013 at 10:47 PM, loial <jldunn2000 at gmail.com> wrote: > I am parseing a file to extract data, but am seeing the file being updated even though I never explicitly write to the file. It is possible that another process is doing this at some later time, but I just want to check that opening the file as follows and ignoring a record would not result in that record being removed from the file. > > I'm damned sure it wouldn't, but just wanted to check with the experts!. > > for line in open("/home/john/myfile"): Absolutely not. You're opening the file (by default) for reading only. That's not going to edit the file in any way. (It might cause the directory entry to be rewritten, eg last-access time, but not the file contents.) Your expectation is 100% correct. ChrisA




More information about the Python-list mailing list