summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-04-01 21:00:55 (GMT)
committerGeorg Brandl <georg@python.org>2009-04-01 21:00:55 (GMT)
commit88ed8f2c502a436e4417800be3fafce4c15ba87a (patch)
tree756105f8b8a912d920e586d1cce3038e378d5d36
parentfff2f4bb03f93610c4375f95790e163cc5a94fd5 (diff)
downloadcpython-88ed8f2c502a436e4417800be3fafce4c15ba87a.zip
cpython-88ed8f2c502a436e4417800be3fafce4c15ba87a.tar.gz
cpython-88ed8f2c502a436e4417800be3fafce4c15ba87a.tar.bz2
#4572: add SEEK_* values as constants in io.py.
-rw-r--r--Doc/library/io.rst12
-rw-r--r--Lib/io.py5
2 files changed, 14 insertions, 3 deletions
diff --git a/Doc/library/io.rst b/Doc/library/io.rst
index fdacabb..df6393c 100644
--- a/Doc/library/io.rst
+++ b/Doc/library/io.rst
@@ -265,12 +265,18 @@ I/O Base Classes
interpreted relative to the position indicated by *whence*. Values for
*whence* are:
- * ``0`` -- start of the stream (the default); *offset* should be zero or positive
- * ``1`` -- current stream position; *offset* may be negative
- * ``2`` -- end of the stream; *offset* is usually negative
+ * :data:`SEEK_SET` or ``0`` -- start of the stream (the default);
+ *offset* should be zero or positive
+ * :data:`SEEK_CUR` or ``1`` -- current stream position; *offset* may
+ be negative
+ * :data:`SEEK_END` or ``2`` -- end of the stream; *offset* is usually
+ negative
Return the new absolute position.
+ .. versionadded:: 2.7
+ The ``SEEK_*`` constants
+
.. method:: seekable()
Return ``True`` if the stream supports random access. If ``False``,
diff --git a/Lib/io.py b/Lib/io.py
index 61206c4..1cf9a18 100644
--- a/Lib/io.py
+++ b/Lib/io.py
@@ -66,6 +66,11 @@ import threading
# open() uses st_blksize whenever we can
DEFAULT_BUFFER_SIZE = 8 * 1024 # bytes
+# for seek()
+SEEK_SET = 0
+SEEK_CUR = 1
+SEEK_END = 2
+
# py3k has only new style classes
__metaclass__ = type