Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1fde8a3

Browse files
committed
Issue #12922: fix the TextIOBase documentation to include a description of seek() and tell() methods.
2 parents a4ac600 + f49d152 commit 1fde8a3

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

Doc/library/io.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,32 @@ Text I/O
713713
Read until newline or EOF and return a single ``str``. If the stream is
714714
already at EOF, an empty string is returned.
715715

716+
.. method:: seek(offset, whence=SEEK_SET)
717+
718+
Change the stream position to the given *offset*. Behaviour depends
719+
on the *whence* parameter:
720+
721+
* :data:`SEEK_SET` or ``0``: seek from the start of the stream
722+
(the default); *offset* must either be a number returned by
723+
:meth:`TextIOBase.tell`, or zero. Any other *offset* value
724+
produces undefined behaviour.
725+
* :data:`SEEK_CUR` or ``1``: "seek" to the current position;
726+
*offset* must be zero, which is a no-operation (all other values
727+
are unsupported).
728+
* :data:`SEEK_END` or ``2``: seek to the end of the stream;
729+
*offset* must be zero (all other values are unsupported).
730+
731+
Return the new absolute position as an opaque number.
732+
733+
.. versionadded:: 3.1
734+
The ``SEEK_*`` constants.
735+
736+
.. method:: tell()
737+
738+
Return the current stream position as an opaque number. The number
739+
does not usually represent a number of bytes in the underlying
740+
binary storage.
741+
716742
.. method:: write(s)
717743

718744
Write the string *s* to the stream and return the number of characters

0 commit comments

Comments
 (0)