]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106318: Add examples for str.partition() method (#142823)
authorAdorilson Bezerra <adorilson@gmail.com>
Sun, 8 Feb 2026 22:10:43 +0000 (22:10 +0000)
committerGitHub <noreply@github.com>
Sun, 8 Feb 2026 22:10:43 +0000 (00:10 +0200)
Doc/library/stdtypes.rst

index 4fc6f3b96521655f96426ea916082481b9be196b..b8c079faa93d6d229135e4462f3ce29f2aa77ddd 100644 (file)
@@ -2483,6 +2483,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, /)