Skip to content

Commit 92a6c3d

Browse files
gh-69619: Link to isspace() in the strip() and split() documentation
The methods that default to removing or splitting on whitespace now link to str.isspace() and bytes.isspace(), where whitespace is defined.
1 parent b5c74a6 commit 92a6c3d

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
@@ -2590,7 +2590,8 @@ expression support in the :mod:`re` module).
25902590

25912591
Return a list of the words in the string, using *sep* as the delimiter string.
25922592
If *maxsplit* is given, at most *maxsplit* splits are done, the *rightmost*
2593-
ones. If *sep* is not specified or ``None``, any whitespace string is a
2593+
ones. If *sep* is not specified or ``None``, any
2594+
:meth:`whitespace <str.isspace>` string is a
25942595
separator. Except for splitting from the right, :meth:`rsplit` behaves like
25952596
:meth:`split` which is described in detail below.
25962597

@@ -2651,7 +2652,8 @@ expression support in the :mod:`re` module).
26512652
['1', '2', '3<4']
26522653

26532654
If *sep* is not specified or is ``None``, a different splitting algorithm is
2654-
applied: runs of consecutive whitespace are regarded as a single separator,
2655+
applied: runs of consecutive :meth:`whitespace <str.isspace>` are regarded
2656+
as a single separator,
26552657
and the result will contain no empty strings at the start or end if the
26562658
string has leading or trailing whitespace. Consequently, splitting an empty
26572659
string or a string consisting of just whitespace with a ``None`` separator
@@ -3915,7 +3917,8 @@ produce new objects.
39153917
Return a copy of the sequence with specified leading bytes removed. The
39163918
*bytes* argument is a binary sequence specifying the set of byte values to
39173919
be removed. If omitted or ``None``, the *bytes* argument defaults
3918-
to removing ASCII whitespace. The *bytes* argument is not a prefix;
3920+
to removing :meth:`ASCII whitespace <bytes.isspace>`.
3921+
The *bytes* argument is not a prefix;
39193922
rather, all combinations of its values are stripped::
39203923

39213924
>>> b' spacious '.lstrip()
@@ -3959,7 +3962,8 @@ produce new objects.
39593962
Split the binary sequence into subsequences of the same type, using *sep*
39603963
as the delimiter string. If *maxsplit* is given, at most *maxsplit* splits
39613964
are done, the *rightmost* ones. If *sep* is not specified or ``None``,
3962-
any subsequence consisting solely of ASCII whitespace is a separator.
3965+
any subsequence consisting solely of
3966+
:meth:`ASCII whitespace <bytes.isspace>` is a separator.
39633967
Except for splitting from the right, :meth:`rsplit` behaves like
39643968
:meth:`split` which is described in detail below.
39653969

@@ -3970,7 +3974,8 @@ produce new objects.
39703974
Return a copy of the sequence with specified trailing bytes removed. The
39713975
*bytes* argument is a binary sequence specifying the set of byte values to
39723976
be removed. If omitted or ``None``, the *bytes* argument defaults to
3973-
removing ASCII whitespace. The *bytes* argument is not a suffix; rather,
3977+
removing :meth:`ASCII whitespace <bytes.isspace>`.
3978+
The *bytes* argument is not a suffix; rather,
39743979
all combinations of its values are stripped::
39753980

39763981
>>> b' spacious '.rstrip()
@@ -4023,7 +4028,8 @@ produce new objects.
40234028
[b'1', b'2', b'3<4']
40244029

40254030
If *sep* is not specified or is ``None``, a different splitting algorithm
4026-
is applied: runs of consecutive ASCII whitespace are regarded as a single
4031+
is applied: runs of consecutive :meth:`ASCII whitespace <bytes.isspace>`
4032+
are regarded as a single
40274033
separator, and the result will contain no empty strings at the start or
40284034
end if the sequence has leading or trailing whitespace. Consequently,
40294035
splitting an empty sequence or a sequence consisting solely of ASCII
@@ -4046,7 +4052,8 @@ produce new objects.
40464052
Return a copy of the sequence with specified leading and trailing bytes
40474053
removed. The *bytes* argument is a binary sequence specifying the set of
40484054
byte values to be removed. If omitted or ``None``, the *bytes*
4049-
argument defaults to removing ASCII whitespace. The *bytes* argument is
4055+
argument defaults to removing :meth:`ASCII whitespace <bytes.isspace>`.
4056+
The *bytes* argument is
40504057
not a prefix or suffix; rather, all combinations of its values are
40514058
stripped::
40524059

0 commit comments

Comments
 (0)