Message336564
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
>>> |
|
Date |
User |
Action |
Args |
2019-02-25 22:12:02 | ngie | set | recipients:
+ ngie |
2019-02-25 22:12:02 | ngie | set | messageid: <1551132722.44.0.748659725129.issue36111@roundup.psfhosted.org> |
2019-02-25 22:12:02 | ngie | link | issue36111 messages |
2019-02-25 22:12:02 | ngie | create | |
|