handle = open('/tmp/lines.txt')
help(handle.seek)
Help on built-in function seek:
seek(cookie, whence=0, /) method of _io.TextIOWrapper instance
Change stream position.
Change the stream position to the given byte offset. The offset is
interpreted relative to the position indicated by whence. Values
for whence are:
* 0 -- start of stream (the default); offset should be zero or positive
* 1 -- current stream position; offset may be negative
* 2 -- end of stream; offset is usually negative
Return the new absolute position.
Generally, the behaviour is very inconsistent, seek relative to the end fail, seek relative to the start works, but might yield a situation when read fails.
Documentation
The documentation on text handles is misleading, in particular for the
seekmethod.Steps to reproduce
This produces the following documentation:
Issues
osmodule, likeos.SEEK_ENDare not mentioned.Generally, the behaviour is very inconsistent, seek relative to the end fail, seek relative to the start works, but might yield a situation when
readfails.Full investigation of the issue
Linked PRs