Skip to content

Commit eb551d9

Browse files
serhiy-storchakamiss-islington
authored andcommitted
gh-69619: Link to isspace() in the strip() and split() documentation (GH-155444)
The methods that default to removing or splitting on whitespace now link to str.isspace() and bytes.isspace(), where whitespace is defined. (cherry picked from commit aca38ab) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent ed58355 commit eb551d9

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

Doc/library/stdtypes.rst

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2585,7 +2585,8 @@ expression support in the :mod:`re` module).
25852585

25862586
Return a list of the words in the string, using *sep* as the delimiter string.
25872587
If *maxsplit* is given, at most *maxsplit* splits are done, the *rightmost*
2588-
ones. If *sep* is not specified or ``None``, any whitespace string is a
2588+
ones. If *sep* is not specified or ``None``, any
2589+
:meth:`whitespace <str.isspace>` string is a
25892590
separator. Except for splitting from the right, :meth:`rsplit` behaves like
25902591
:meth:`split` which is described in detail below.
25912592

@@ -2645,7 +2646,8 @@ expression support in the :mod:`re` module).
26452646
['1', '2', '3<4']
26462647

26472648
If *sep* is not specified or is ``None``, a different splitting algorithm is
2648-
applied: runs of consecutive whitespace are regarded as a single separator,
2649+
applied: runs of consecutive :meth:`whitespace <str.isspace>` are regarded
2650+
as a single separator,
26492651
and the result will contain no empty strings at the start or end if the
26502652
string has leading or trailing whitespace. Consequently, splitting an empty
26512653
string or a string consisting of just whitespace with a ``None`` separator
@@ -3875,7 +3877,8 @@ produce new objects.
38753877
Return a copy of the sequence with specified leading bytes removed. The
38763878
*bytes* argument is a binary sequence specifying the set of byte values to
38773879
be removed. If omitted or ``None``, the *bytes* argument defaults
3878-
to removing ASCII whitespace. The *bytes* argument is not a prefix;
3880+
to removing :meth:`ASCII whitespace <bytes.isspace>`.
3881+
The *bytes* argument is not a prefix;
38793882
rather, all combinations of its values are stripped::
38803883

38813884
>>> b' spacious '.lstrip()
@@ -3919,7 +3922,8 @@ produce new objects.
39193922
Split the binary sequence into subsequences of the same type, using *sep*
39203923
as the delimiter string. If *maxsplit* is given, at most *maxsplit* splits
39213924
are done, the *rightmost* ones. If *sep* is not specified or ``None``,
3922-
any subsequence consisting solely of ASCII whitespace is a separator.
3925+
any subsequence consisting solely of
3926+
:meth:`ASCII whitespace <bytes.isspace>` is a separator.
39233927
Except for splitting from the right, :meth:`rsplit` behaves like
39243928
:meth:`split` which is described in detail below.
39253929

@@ -3930,7 +3934,8 @@ produce new objects.
39303934
Return a copy of the sequence with specified trailing bytes removed. The
39313935
*bytes* argument is a binary sequence specifying the set of byte values to
39323936
be removed. If omitted or ``None``, the *bytes* argument defaults to
3933-
removing ASCII whitespace. The *bytes* argument is not a suffix; rather,
3937+
removing :meth:`ASCII whitespace <bytes.isspace>`.
3938+
The *bytes* argument is not a suffix; rather,
39343939
all combinations of its values are stripped::
39353940

39363941
>>> b' spacious '.rstrip()
@@ -3983,7 +3988,8 @@ produce new objects.
39833988
[b'1', b'2', b'3<4']
39843989

39853990
If *sep* is not specified or is ``None``, a different splitting algorithm
3986-
is applied: runs of consecutive ASCII whitespace are regarded as a single
3991+
is applied: runs of consecutive :meth:`ASCII whitespace <bytes.isspace>`
3992+
are regarded as a single
39873993
separator, and the result will contain no empty strings at the start or
39883994
end if the sequence has leading or trailing whitespace. Consequently,
39893995
splitting an empty sequence or a sequence consisting solely of ASCII
@@ -4006,7 +4012,8 @@ produce new objects.
40064012
Return a copy of the sequence with specified leading and trailing bytes
40074013
removed. The *bytes* argument is a binary sequence specifying the set of
40084014
byte values to be removed. If omitted or ``None``, the *bytes*
4009-
argument defaults to removing ASCII whitespace. The *bytes* argument is
4015+
argument defaults to removing :meth:`ASCII whitespace <bytes.isspace>`.
4016+
The *bytes* argument is
40104017
not a prefix or suffix; rather, all combinations of its values are
40114018
stripped::
40124019

0 commit comments

Comments
 (0)