From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sun, 8 Feb 2026 22:17:46 +0000 (+0100) Subject: [3.14] gh-106318: Add examples for str.partition() method (GH-142823) (#144611) X-Git-Tag: v3.14.4~315 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=27baa1cd5d0d2d3052147786e50fa549574c2ce2;p=thirdparty%2FPython%2Fcpython.git [3.14] gh-106318: Add examples for str.partition() method (GH-142823) (#144611) gh-106318: Add examples for str.partition() method (GH-142823) (cherry picked from commit 432ddd99e2b06a75a4f47bd99c0fd0c911bdb19c) Co-authored-by: Adorilson Bezerra --- diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 07c73e16e6aa..4f5abcc8dd2a 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -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, /)