Skip to content

Commit 95e2ea3

Browse files
adorilsonmiss-islington
authored andcommitted
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 0cc73ad commit 95e2ea3

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

2475+
For example:
2476+
2477+
.. doctest::
2478+
2479+
>>> 'Monty Python'.partition(' ')
2480+
('Monty', ' ', 'Python')
2481+
>>> "Monty Python's Flying Circus".partition(' ')
2482+
('Monty', ' ', "Python's Flying Circus")
2483+
>>> 'Monty Python'.partition('-')
2484+
('Monty Python', '', '')
2485+
2486+
See also :meth:`rpartition`.
2487+
24752488

24762489
.. method:: str.removeprefix(prefix, /)
24772490

0 commit comments

Comments
 (0)