From 1b401b428ce42fbe7eae9ad373aedd3d0fd6848f Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Thu, 15 Jan 2026 20:32:04 +0000 Subject: [PATCH 1/2] gh-106318: Add doctest role to str.rsplit() method --- Doc/library/stdtypes.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 22bc1536c1a37b..955d8f552797d9 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2577,7 +2577,11 @@ expression support in the :mod:`re` module). Return a copy of the string with 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 suffix; rather, all combinations of its values are stripped:: + argument is not a suffix; rather, all combinations of its values are stripped: + + For example: + + .. doctest:: >>> ' spacious '.rstrip() ' spacious' @@ -2592,6 +2596,7 @@ expression support in the :mod:`re` module). >>> 'Monty Python'.removesuffix(' Python') 'Monty' + .. method:: str.split(sep=None, maxsplit=-1) Return a list of the words in the string, using *sep* as the delimiter From 9fa3eccac48c518dbc4a1f215cb8ba6cfb93e980 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Thu, 15 Jan 2026 20:45:38 +0000 Subject: [PATCH 2/2] gh-106318: Remove str.removesuffix() example from str.rsplit() method doc str.removesuffix() docs have their own examples. --- Doc/library/stdtypes.rst | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 955d8f552797d9..bc74a7fe8086fa 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2588,13 +2588,7 @@ expression support in the :mod:`re` module). >>> 'mississippi'.rstrip('ipz') 'mississ' - See :meth:`str.removesuffix` for a method that will remove a single suffix - string rather than all of a set of characters. For example:: - - >>> 'Monty Python'.rstrip(' Python') - 'M' - >>> 'Monty Python'.removesuffix(' Python') - 'Monty' + See also :meth:`strip` and :meth:`removesuffix`. .. method:: str.split(sep=None, maxsplit=-1)