]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-106318: Add examples for str.partition() method (GH-142823) (#144612)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 8 Feb 2026 22:16:49 +0000 (23:16 +0100)
committerGitHub <noreply@github.com>
Sun, 8 Feb 2026 22:16:49 +0000 (22:16 +0000)
gh-106318: Add examples for str.partition() method (GH-142823)
(cherry picked from commit 432ddd99e2b06a75a4f47bd99c0fd0c911bdb19c)

Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
Doc/library/stdtypes.rst

index 997e897c29e3841e29a2692ff8a1927c1edf6fd5..544475c807cbfb26d81b4c7674b0f59f4c3b25c3 100644 (file)
@@ -2242,6 +2242,19 @@ 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's Flying Circus".partition(' ')
+      ('Monty', ' ', "Python's Flying Circus")
+      >>> 'Monty Python'.partition('-')
+      ('Monty Python', '', '')
+
+   See also :meth:`rpartition`.
+
 
 .. method:: str.removeprefix(prefix, /)