Skip to content

Commit 38afa4a

Browse files
gh-107801: Document io.TextIOWrapper.tell (#108265)
1 parent a429eaf commit 38afa4a

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

Doc/library/io.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1054,13 +1054,21 @@ Text I/O
10541054

10551055
* ``seek(0, SEEK_SET)``: Rewind to the start of the stream.
10561056
* ``seek(cookie, SEEK_SET)``: Restore a previous position;
1057-
*cookie* **must be** a number returned by :meth:`!tell`.
1057+
*cookie* **must be** a number returned by :meth:`tell`.
10581058
* ``seek(0, SEEK_END)``: Fast-forward to the end of the stream.
10591059
* ``seek(0, SEEK_CUR)``: Leave the current stream position unchanged.
10601060

10611061
Any other argument combinations are invalid,
10621062
and may raise exceptions.
10631063

1064+
.. method:: tell()
1065+
1066+
Return the stream position as an opaque number.
1067+
The return value of :meth:`!tell` can be given as input to :meth:`seek`,
1068+
to restore a previous stream position.
1069+
1070+
1071+
10641072
.. class:: StringIO(initial_value='', newline='\n')
10651073

10661074
A text stream using an in-memory text buffer. It inherits

Modules/_io/clinic/textio.c.h

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/textio.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2640,11 +2640,16 @@ _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence)
26402640

26412641
/*[clinic input]
26422642
_io.TextIOWrapper.tell
2643+
2644+
Return the stream position as an opaque number.
2645+
2646+
The return value of tell() can be given as input to seek(), to restore a
2647+
previous stream position.
26432648
[clinic start generated code]*/
26442649

26452650
static PyObject *
26462651
_io_TextIOWrapper_tell_impl(textio *self)
2647-
/*[clinic end generated code: output=4f168c08bf34ad5f input=9a2caf88c24f9ddf]*/
2652+
/*[clinic end generated code: output=4f168c08bf34ad5f input=0852d627d76fb520]*/
26482653
{
26492654
PyObject *res;
26502655
PyObject *posobj = NULL;

0 commit comments

Comments
 (0)