Skip to content

Commit 6884288

Browse files
[3.13] gh-106318: Add examples for str.partition() method (GH-142823) (#144612)
gh-106318: Add examples for str.partition() method (GH-142823) (cherry picked from commit 432ddd9) Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
1 parent 43b9344 commit 6884288

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Doc/library/stdtypes.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,6 +2242,19 @@ expression support in the :mod:`re` module).
22422242
after the separator. If the separator is not found, return a 3-tuple containing
22432243
the string itself, followed by two empty strings.
22442244

2245+
For example:
2246+
2247+
.. doctest::
2248+
2249+
>>> 'Monty Python'.partition(' ')
2250+
('Monty', ' ', 'Python')
2251+
>>> "Monty Python's Flying Circus".partition(' ')
2252+
('Monty', ' ', "Python's Flying Circus")
2253+
>>> 'Monty Python'.partition('-')
2254+
('Monty Python', '', '')
2255+
2256+
See also :meth:`rpartition`.
2257+
22452258

22462259
.. method:: str.removeprefix(prefix, /)
22472260

0 commit comments

Comments
 (0)