From 8661e67b594c4c373dd2eb98f18ba1d1ac3b55aa Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Thu, 15 Jan 2026 18:53:08 +0000 Subject: [PATCH 1/4] gh-106318: Add example for str.rindex() method --- Doc/library/stdtypes.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 22bc1536c1a37b..88c3b2d78eae97 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2546,6 +2546,18 @@ expression support in the :mod:`re` module). Like :meth:`rfind` but raises :exc:`ValueError` when the substring *sub* is not found. + For example: + + .. doctest:: + + >>> 'spam, spam, spam'.rindex('eggs') + Traceback (most recent call last): + File "", line 1, in + 'spam, spam, spam'.rindex('eggs') + ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^ + ValueError: substring not found + + See also :meth:`index` and :meth:`find`. .. method:: str.rjust(width, fillchar=' ', /) From 140d99b37bf3d72d0d0821cd91c17e63586b5212 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Mon, 2 Feb 2026 21:36:56 +0000 Subject: [PATCH 2/4] gh-106318: Add a successful example for str.rindex() method --- Doc/library/stdtypes.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 88c3b2d78eae97..2b834f46d5e11c 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2550,6 +2550,8 @@ expression support in the :mod:`re` module). .. doctest:: + >>> 'spam, spam, spam'.rindex('spam') + 12 >>> 'spam, spam, spam'.rindex('eggs') Traceback (most recent call last): File "", line 1, in @@ -2740,7 +2742,7 @@ expression support in the :mod:`re` module). Return a copy of the string with the leading and trailing characters removed. The *chars* argument is a string specifying the set of characters to be removed. If omitted or ``None``, the *chars* argument defaults to removing whitespace. - The *chars* argument is not a prefix or suffix; rather, all combinations of its + The *chars* argument is not a prefix or suffix; rather, all comrbinations of its values are stripped:: >>> ' spacious '.strip() From 08a4a431db95615c74baa312678b4fa9d1b6158b Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Mon, 2 Feb 2026 21:39:51 +0000 Subject: [PATCH 3/4] gh-106318: Fix typo --- Doc/library/stdtypes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 2b834f46d5e11c..f4fb820b805768 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2742,7 +2742,7 @@ expression support in the :mod:`re` module). Return a copy of the string with the leading and trailing characters removed. The *chars* argument is a string specifying the set of characters to be removed. If omitted or ``None``, the *chars* argument defaults to removing whitespace. - The *chars* argument is not a prefix or suffix; rather, all comrbinations of its + The *chars* argument is not a prefix or suffix; rather, all combinations of its values are stripped:: >>> ' spacious '.strip() From df2492e853076d6d2279da1ed60ae6c92ca301e5 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Mon, 2 Feb 2026 22:18:08 +0000 Subject: [PATCH 4/4] gh-106318: Add a successful example for str.index() method --- Doc/library/stdtypes.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index f4fb820b805768..4856078899c033 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2163,6 +2163,8 @@ expression support in the :mod:`re` module). .. doctest:: + >>> 'spam, spam, spam'.index('spam') + 0 >>> 'spam, spam, spam'.index('eggs') Traceback (most recent call last): File "", line 1, in