Skip to content

Commit 35ec255

Browse files
[3.14] gh-106318: Add doctest role and a 'See also' to the str.split() docs (GH-144367)
(cherry picked from commit a96cba5) Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
1 parent 6c6f04d commit 35ec255

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

Doc/library/stdtypes.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2612,7 +2612,9 @@ expression support in the :mod:`re` module).
26122612
:func:`re.split`). Splitting an empty string with a specified separator
26132613
returns ``['']``.
26142614

2615-
For example::
2615+
For example:
2616+
2617+
.. doctest::
26162618

26172619
>>> '1,2,3'.split(',')
26182620
['1', '2', '3']
@@ -2630,7 +2632,9 @@ expression support in the :mod:`re` module).
26302632
string or a string consisting of just whitespace with a ``None`` separator
26312633
returns ``[]``.
26322634

2633-
For example::
2635+
For example:
2636+
2637+
.. doctest::
26342638

26352639
>>> '1 2 3'.split()
26362640
['1', '2', '3']
@@ -2642,7 +2646,9 @@ expression support in the :mod:`re` module).
26422646
If *sep* is not specified or is ``None`` and *maxsplit* is ``0``, only
26432647
leading runs of consecutive whitespace are considered.
26442648

2645-
For example::
2649+
For example:
2650+
2651+
.. doctest::
26462652

26472653
>>> "".split(None, 0)
26482654
[]
@@ -2651,7 +2657,7 @@ expression support in the :mod:`re` module).
26512657
>>> " foo ".split(maxsplit=0)
26522658
['foo ']
26532659

2654-
See also :meth:`join`.
2660+
See also :meth:`join` and :meth:`rsplit`.
26552661

26562662

26572663
.. index::

0 commit comments

Comments
 (0)