This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: file.write() after file.read() adds text to the end of the file
Type: behavior Stage: resolved
Components: IO Versions: Python 3.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder: TextIOWrapper: issues with interlaced read-write
View: 12215
Assigned To: Nosy List: Adam Wasik
Priority: normal Keywords:

Created on 2015-12-20 09:44 by Adam Wasik, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg256756 - (view) Author: Adam Wasik (Adam Wasik) Date: 2015-12-20 09:44
>>> 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
>>>
msg256758 - (view) Author: Adam Wasik (Adam Wasik) Date: 2015-12-20 09:55
duplicate of the issue #12215
History
Date User Action Args
2022-04-11 14:58:25adminsetgithub: 70103
2015-12-20 09:56:50SilentGhostsettype: behavior
superseder: TextIOWrapper: issues with interlaced read-write
resolution: duplicate
stage: resolved
2015-12-20 09:55:38Adam Wasiksetstatus: open -> closed

messages: + msg256758
2015-12-20 09:44:25Adam Wasikcreate