From 501a327a2b0cf2e0107788418aa1f65aaf9250f1 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Wed, 12 May 2021 19:29:37 -0300 Subject: [PATCH 1/4] gh-106318: Add examples for str.partition() method --- Doc/library/stdtypes.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index f33b73238ec8b3..feee9d6da77dc8 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2329,6 +2329,15 @@ expression support in the :mod:`re` module). after the separator. If the separator is not found, return a 3-tuple containing the string itself, followed by two empty strings. + For example: + + .. doctest:: + + >>> 'Monty Python'.partition(' ') + ('Monty', ' ', 'Python') + >>> 'Monty Python'.partition('-') + ('Monty Python', '', '') + .. method:: str.removeprefix(prefix, /) From e53633b7694a2873b1de0e484cb937bfbcbf6a9a Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Tue, 16 Dec 2025 13:26:10 +0000 Subject: [PATCH 2/4] gh-106318: Add 'See also rpartition()' on str.partition() method --- Doc/library/stdtypes.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index feee9d6da77dc8..a927a0049db730 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2338,6 +2338,8 @@ expression support in the :mod:`re` module). >>> 'Monty Python'.partition('-') ('Monty Python', '', '') + See also :meth:`rpartition`. + .. method:: str.removeprefix(prefix, /) From d714e42351f60a9addaee9e212685c4cdb339c9f Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sun, 11 Jan 2026 13:17:03 +0000 Subject: [PATCH 3/4] gh-106318: Add a third example for str.partition() method --- Doc/library/stdtypes.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index a927a0049db730..0fec05780ea87e 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2335,6 +2335,8 @@ expression support in the :mod:`re` module). >>> 'Monty Python'.partition(' ') ('Monty', ' ', 'Python') + >>> "Monty Python's Flying Circus".partition(' ') + ('Monty', ' ', "Python's Flying Circus") >>> 'Monty Python'.partition('-') ('Monty Python', '', '') From 9de07db023a83444b39542be153289a9623f3837 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sun, 11 Jan 2026 13:24:59 +0000 Subject: [PATCH 4/4] gh-106318: Fix indent on the str.partition() method --- 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 0fec05780ea87e..7ddffcbb4efdc7 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2340,7 +2340,7 @@ expression support in the :mod:`re` module). >>> 'Monty Python'.partition('-') ('Monty Python', '', '') - See also :meth:`rpartition`. + See also :meth:`rpartition`. .. method:: str.removeprefix(prefix, /)