[Python-checkins] cpython (2.7): Issue #12922: fix the TextIOBase documentation to include a description of

antoine.pitrou python-checkins at python.org
Sat Jan 21 20:30:16 CET 2012


http://hg.python.org/cpython/rev/fcf4d547bed8
changeset:   74560:fcf4d547bed8
branch:      2.7
parent:      74556:91cbac92a665
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Sat Jan 21 20:27:59 2012 +0100
summary:
  Issue #12922: fix the TextIOBase documentation to include a description of seek() and tell() methods.

files:
  Doc/library/io.rst |  26 ++++++++++++++++++++++++++
  1 files changed, 26 insertions(+), 0 deletions(-)


diff --git a/Doc/library/io.rst b/Doc/library/io.rst
--- a/Doc/library/io.rst
+++ b/Doc/library/io.rst
@@ -701,6 +701,32 @@
       Read until newline or EOF and return a single ``unicode``.  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:: 2.7
+         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 :class:`unicode` string *s* to the stream and return the

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list