Skip to content

Commit 27baa1c

Browse files
[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 432ddd9) Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
1 parent 2494a90 commit 27baa1c

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
@@ -2483,6 +2483,19 @@ expression support in the :mod:`re` module).
24832483
after the separator. If the separator is not found, return a 3-tuple containing
24842484
the string itself, followed by two empty strings.
24852485

2486+
For example:
2487+
2488+
.. doctest::
2489+
2490+
>>> 'Monty Python'.partition(' ')
2491+
('Monty', ' ', 'Python')
2492+
>>> "Monty Python's Flying Circus".partition(' ')
2493+
('Monty', ' ', "Python's Flying Circus")
2494+
>>> 'Monty Python'.partition('-')
2495+
('Monty Python', '', '')
2496+
2497+
See also :meth:`rpartition`.
2498+
24862499

24872500
.. method:: str.removeprefix(prefix, /)
24882501

0 commit comments

Comments
 (0)