Title: Documentation - io — Core tools for working with streams - seek()
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.8, Python 3.7, Python 3.6, Python 3.4, Python 3.5, Python 2.7
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Mikhail Zakharov, docs@python, josh.r
Priority: normal Keywords:

Created on 2018-04-05 09:08 by Mikhail Zakharov, last changed 2018-04-08 08:11 by Mikhail Zakharov. This issue is now closed.

Messages (4)
msg314970 - (view) Author: Mikhail Zakharov (Mikhail Zakharov) Date: 2018-04-05 09:08
Documentation for io.IOBase class and it's seek() method at mentions SEEK_* constants like:

"    SEEK_SET or 0 – start of the stream (the default); offset should be zero or positive
    SEEK_CUR or 1 – current stream position; offset may be negative
    SEEK_END or 2 – end of the stream; offset is usually negative

It seems, they actually should be used as os.SEEK_SET, os.SEEK_CUR and os.SEEK_END.
msg314982 - (view) Author: Josh Rosenberg (josh.r) * (Python triager) Date: 2018-04-05 13:41
As indicated in the seek docs ( ), all three names were added to the io module in 3.1:

> New in version 3.1: The SEEK_* constants.

Since they're part of the io module too, there is no need to qualify them on the io module docs page.

They're available in os as well, but you don't need to import it to use them. The OS specific addition position flags are explicitly documented to be found on the os module.
msg314984 - (view) Author: Mikhail Zakharov (Mikhail Zakharov) Date: 2018-04-05 14:01
Seems in my, quite old 3.4.5 version, it doesn't work:

$ python3
Python 3.4.5 (default, Jun  1 2017, 13:52:39) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> f = open('/tmp/text.txt', 'r')
>>>, SEEK_END)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'SEEK_END' is not defined
>>> f.close()
>>> import os
>>> f = open('/tmp/text.txt', 'r')
>>>, os.SEEK_END)
>>> f.close()
msg314985 - (view) Author: Mikhail Zakharov (Mikhail Zakharov) Date: 2018-04-05 14:11
OK, I got it. Sorry for disturbing you.

The should be called like: io.SEEK_*
Date User Action Args
2018-04-08 08:11:43Mikhail Zakharovsetstatus: open -> closed
stage: resolved
2018-04-05 14:11:54Mikhail Zakharovsetmessages: + msg314985
2018-04-05 14:01:46Mikhail Zakharovsetmessages: + msg314984
2018-04-05 13:41:06josh.rsetnosy: + josh.r
messages: + msg314982
2018-04-05 09:08:37Mikhail Zakharovcreate