changeset 74558:03e61104f7a2 3.2

Issue #12922: fix the TextIOBase documentation to include a description of seek() and tell() methods.
author Antoine Pitrou <solipsis@pitrou.net>
date Sat, 21 Jan 2012 20:20:49 +0100
parents 79e7c5841e66
children f7e5abfb31ea d01fecadf3ea
files Doc/library/io.rst
diffstat 1 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Doc/library/io.rst	Sat Jan 21 10:59:37 2012 +0100
+++ b/Doc/library/io.rst	Sat Jan 21 20:20:49 2012 +0100
@@ -704,6 +704,32 @@
       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