Re: interaction of mode 'r+', file.write(), and file.tell(): a bug or undefined behavior?

2010-02-01 Thread Aahz
In article 4b617f4...@dnews.tpgi.com.au, Lie Ryan lie.1...@gmail.com wrote: f = open('input.txt', 'r+') for line in f: s = line.replace('python', 'PYTHON') # f.tell() f.write(s) When f.tell() is commented, 'input.txt' does not change; but when uncommented, the f.write() succeeded

interaction of mode 'r+', file.write(), and file.tell(): a bug or undefined behavior?

2010-01-28 Thread Lie Ryan
In the code: f = open('input.txt', 'r+') for line in f: s = line.replace('python', 'PYTHON') # f.tell() f.write(s) When f.tell() is commented, 'input.txt' does not change; but when uncommented, the f.write() succeeded writing into the 'input.txt' (surprisingly, but not entirely

Re: interaction of mode 'r+', file.write(), and file.tell(): a bug or undefined behavior?

2010-01-28 Thread Anthony Tolle
On Jan 28, 7:12 am, Lie Ryan lie.1...@gmail.com wrote: In the code: f = open('input.txt', 'r+') for line in f:     s = line.replace('python', 'PYTHON')     # f.tell()     f.write(s) [snip] My guess is that there are a few possible problems: 1) In this case, writing to file opened

Re: interaction of mode 'r+', file.write(), and file.tell(): a bug or undefined behavior?

2010-01-28 Thread Alf P. Steinbach
* Anthony Tolle: On Jan 28, 7:12 am, Lie Ryan lie.1...@gmail.com wrote: In the code: f = open('input.txt', 'r+') for line in f: s = line.replace('python', 'PYTHON') # f.tell() f.write(s) [snip] My guess is that there are a few possible problems: 1) In this case, writing to