Skip to content

Commit 7f7b98d

Browse files
committed
gh-106318: Add doctest role for str.splitlines() examples
1 parent ccbe41e commit 7f7b98d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Doc/library/stdtypes.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2704,7 +2704,9 @@ expression support in the :mod:`re` module).
27042704

27052705
``\v`` and ``\f`` added to list of line boundaries.
27062706

2707-
For example::
2707+
For example:
2708+
2709+
.. doctest::
27082710

27092711
>>> 'ab c\n\nde fg\rkl\r\n'.splitlines()
27102712
['ab c', '', 'de fg', 'kl']
@@ -2713,14 +2715,18 @@ expression support in the :mod:`re` module).
27132715

27142716
Unlike :meth:`~str.split` when a delimiter string *sep* is given, this
27152717
method returns an empty list for the empty string, and a terminal line
2716-
break does not result in an extra line::
2718+
break does not result in an extra line:
2719+
2720+
.. doctest::
27172721

27182722
>>> "".splitlines()
27192723
[]
27202724
>>> "One line\n".splitlines()
27212725
['One line']
27222726

2723-
For comparison, ``split('\n')`` gives::
2727+
For comparison, ``split('\n')`` gives:
2728+
2729+
.. doctest::
27242730

27252731
>>> ''.split('\n')
27262732
['']

0 commit comments

Comments
 (0)