New submission from Enji Cooper <yaneurab...@gmail.com>:
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 >>> ---------- components: IO messages: 336564 nosy: yaneurabeya priority: normal severity: normal status: open title: Negative `offset` values are no longer acceptable with implementation of `seek` with python3; should be per POSIX _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36111> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com