From: Adorilson Bezerra Date: Sun, 8 Feb 2026 22:10:43 +0000 (+0000) Subject: gh-106318: Add examples for str.partition() method (#142823) X-Git-Tag: v3.15.0a6~35 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=432ddd99e2b06a75a4f47bd99c0fd0c911bdb19c;p=thirdparty%2FPython%2Fcpython.git gh-106318: Add examples for str.partition() method (#142823) --- diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 4fc6f3b96521..b8c079faa93d 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, /)