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.

Author ngie
Recipients ngie
Date 2019-02-25.22:12:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1551132722.44.0.748659725129.issue36111@roundup.psfhosted.org>
In-reply-to
Content
I tried using os.SEEK_END in a technical interview, but unfortunately, that didn't work with python 3.x:

pinklady:cpython ngie$ python3
Python 3.7.2 (default, Feb 12 2019, 08:15:36) 
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> fp = open("configure"); fp.seek(-100, os.SEEK_END)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
io.UnsupportedOperation: can't do nonzero end-relative seeks

It does however work with 2.x, which is aligned with the POSIX spec implementation, as shown below:

pinklady:cpython ngie$ python
Python 2.7.15 (default, Oct  2 2018, 11:47:18) 
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> fp = open("configure"); fp.seek(-100, os.SEEK_END)
>>> fp.tell()
501076
>>> os.stat("configure").st_size
501176
>>>
History
Date User Action Args
2019-02-25 22:12:02ngiesetrecipients: + ngie
2019-02-25 22:12:02ngiesetmessageid: <1551132722.44.0.748659725129.issue36111@roundup.psfhosted.org>
2019-02-25 22:12:02ngielinkissue36111 messages
2019-02-25 22:12:02ngiecreate