Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
Open
Description
The following produces a file containingb'hello\n '
, i.e.hello
followed by a newline and a space:
withopen("asd.txt","w")asfile:file.write("hello\n")withopen("asd.txt","r+")asfile:file.read(4)file.write(" ")
But if I addfile.seek(file.tell())
, then it instead producesb'hell \n'
as I would expect:
withopen("asd.txt","w")asfile:file.write("hello\n")withopen("asd.txt","r+")asfile:file.read(4)file.seek(file.tell())file.write(" ")
Is this correct behaviour? I can't find any mention of it in the docs. (I can't usefile.seek(4)
because that "produces undefined behaviour" according to docs.)