Skip to content

Commit c80f085

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 57aaee5 commit c80f085

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

2234+
For example:
2235+
2236+
.. doctest::
2237+
2238+
>>> 'Monty Python'.partition(' ')
2239+
('Monty', ' ', 'Python')
2240+
>>> "Monty Python's Flying Circus".partition(' ')
2241+
('Monty', ' ', "Python's Flying Circus")
2242+
>>> 'Monty Python'.partition('-')
2243+
('Monty Python', '', '')
2244+
2245+
See also :meth:`rpartition`.
2246+
22342247

22352248
.. method:: str.removeprefix(prefix, /)
22362249

0 commit comments

Comments
 (0)