[New-bugs-announce] [issue25915] file.write() after file.read() adds text to the end of the file

Adam Wasik report at bugs.python.org
Sun Dec 20 04:44:25 EST 2015


New submission from Adam Wasik:

>>> file = open(r"C:\adam.txt","r+")
>>> file.read()
'TEXT TEXT TEXT TEXT TEXT TEXT TEXT\nTEXT TEXT TEXT TEXT TEXT TEXT TEXT\nTEXT TE
XT TEXT TEXT TEXT TEXT TEXT\nTEXT TEXT TEXT TEXT TEXT TEXT TEXT\nTEXT TEXT TEXT
TEXT TEXT TEXT TEXT\nTEXT TEXT TEXT TEXT TEXT TEXT TEXT'
>>> file.seek(0,0)
0
>>> file.read(1)
'T'
>>> file.tell()
1
>>> file.write("NEW")
3
>>> file.tell() # Why 217 rather than 4. Text is added at the end file
217
>>>

----------
components: IO
messages: 256756
nosy: Adam Wasik
priority: normal
severity: normal
status: open
title: file.write() after file.read() adds text to the end of the file
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25915>
_______________________________________


More information about the New-bugs-announce mailing list