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.

classification
Title: add SEEK_* values to io and/or io.IOBase
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.1, Python 2.7
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, gumpy, pitrou
Priority: normal Keywords:

Created on 2008-12-07 04:44 by gumpy, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg77213 - (view) Author: (gumpy) Date: 2008-12-07 04:44
Currently io.IOBase.seek(offset[, whence]) uses magic numbers for the
second argument. Since this is essentially identical the C function
fseek I think adding the same "constants" that C uses (SEEK_SET=0,
SEEK_CUR=1, SEEK_END=2) may be worth considering.

These values could be added to the global scope in the io module:
f = io.open('foo', 'rb')
f.seek(0, io.SEEK_END)

If added to the io.IOBase class then I believe they'd be accessible
without importing io:
f = open('foo', 'rb')
f.seek(0, f.SEEK_END)
msg78678 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-01-01 02:05
Sounds like a nice improvement.
msg85092 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-04-01 21:01
Added in r70992.
History
Date User Action Args
2022-04-11 14:56:42adminsetgithub: 48822
2009-04-01 21:01:02georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg85092

resolution: accepted
2009-01-01 04:06:19benjamin.petersonsetversions: - Python 3.0
2009-01-01 02:05:12pitrousetnosy: + pitrou
messages: + msg78678
2008-12-07 04:44:22gumpycreate