[docs] [issue26158] File truncate() not defaulting to current position as documented
Fornax
report at bugs.python.org
Tue Jan 19 14:38:15 EST 2016
Fornax added the comment:
Another surprising result:
>>> open('temp.txt', 'w').write('ABCDE\nFGHIJ\nKLMNO\nPQRST\nUVWXY\nZ\n')
32
>>> f = open('temp.txt', 'r+')
>>> f.write('test')
4
>>> f.close()
>>> open('temp.txt').read()
'testE\nFGHIJ\nKLMNO\nPQRST\nUVWXY\nZ\n'
>>> open('temp.txt', 'w').write('ABCDE\nFGHIJ\nKLMNO\nPQRST\nUVWXY\nZ\n')
32
>>> f = open('temp.txt', 'r+')
>>> f.write('test')
4
>>> f.read(1)
'A'
>>> f.close()
>>> open('temp.txt').read()
'ABCDE\nFGHIJ\nKLMNO\nPQRST\nUVWXY\nZ\ntest'
The position of the write in the file depends on whether or not there is a subsequent read.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26158>
_______________________________________
More information about the docs
mailing list