summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-01-21 19:22:40 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-01-21 19:22:40 (GMT)
commit1fde8a36ef5cfb0f5639de08805de8a2a524ed87 (patch)
tree46e915c1b396e99ddefc6e6d297cc4791f74a9f1 /Doc
parenta4ac600d6f9c5b74b97b99888b7cf3a7973cadc8 (diff)
parentf49d152ab21ef23c5c71f207d18b81e314264875 (diff)
downloadcpython-1fde8a36ef5cfb0f5639de08805de8a2a524ed87.zip
cpython-1fde8a36ef5cfb0f5639de08805de8a2a524ed87.tar.gz
cpython-1fde8a36ef5cfb0f5639de08805de8a2a524ed87.tar.bz2
Issue #12922: fix the TextIOBase documentation to include a description of seek() and tell() methods.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/io.rst26
1 files changed, 26 insertions, 0 deletions
diff --git a/Doc/library/io.rst b/Doc/library/io.rst
index e1268cb..4d564bb 100644
--- a/Doc/library/io.rst
+++ b/Doc/library/io.rst
@@ -713,6 +713,32 @@ Text I/O
Read until newline or EOF and return a single ``str``. If the stream is
already at EOF, an empty string is returned.
+ .. method:: seek(offset, whence=SEEK_SET)
+
+ Change the stream position to the given *offset*. Behaviour depends
+ on the *whence* parameter:
+
+ * :data:`SEEK_SET` or ``0``: seek from the start of the stream
+ (the default); *offset* must either be a number returned by
+ :meth:`TextIOBase.tell`, or zero. Any other *offset* value
+ produces undefined behaviour.
+ * :data:`SEEK_CUR` or ``1``: "seek" to the current position;
+ *offset* must be zero, which is a no-operation (all other values
+ are unsupported).
+ * :data:`SEEK_END` or ``2``: seek to the end of the stream;
+ *offset* must be zero (all other values are unsupported).
+
+ Return the new absolute position as an opaque number.
+
+ .. versionadded:: 3.1
+ The ``SEEK_*`` constants.
+
+ .. method:: tell()
+
+ Return the current stream position as an opaque number. The number
+ does not usually represent a number of bytes in the underlying
+ binary storage.
+
.. method:: write(s)
Write the string *s* to the stream and return the number of characters