Skip to content

Commit 65cd7e1

Browse files
[3.15] gh-69619: Link to isspace() in the strip() and split() documentation (GH-155444) (#155667)
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 747e518 commit 65cd7e1

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

25952595
Return a list of the words in the string, using *sep* as the delimiter string.
25962596
If *maxsplit* is given, at most *maxsplit* splits are done, the *rightmost*
2597-
ones. If *sep* is not specified or ``None``, any whitespace string is a
2597+
ones. If *sep* is not specified or ``None``, any
2598+
:meth:`whitespace <str.isspace>` string is a
25982599
separator. Except for splitting from the right, :meth:`rsplit` behaves like
25992600
:meth:`split` which is described in detail below.
26002601

@@ -2654,7 +2655,8 @@ expression support in the :mod:`re` module).
26542655
['1', '2', '3<4']
26552656

26562657
If *sep* is not specified or is ``None``, a different splitting algorithm is
2657-
applied: runs of consecutive whitespace are regarded as a single separator,
2658+
applied: runs of consecutive :meth:`whitespace <str.isspace>` are regarded
2659+
as a single separator,
26582660
and the result will contain no empty strings at the start or end if the
26592661
string has leading or trailing whitespace. Consequently, splitting an empty
26602662
string or a string consisting of just whitespace with a ``None`` separator
@@ -3920,7 +3922,8 @@ produce new objects.
39203922
Return a copy of the sequence with specified leading bytes removed. The
39213923
*bytes* argument is a binary sequence specifying the set of byte values to
39223924
be removed. If omitted or ``None``, the *bytes* argument defaults
3923-
to removing ASCII whitespace. The *bytes* argument is not a prefix;
3925+
to removing :meth:`ASCII whitespace <bytes.isspace>`.
3926+
The *bytes* argument is not a prefix;
39243927
rather, all combinations of its values are stripped::
39253928

39263929
>>> b' spacious '.lstrip()
@@ -3964,7 +3967,8 @@ produce new objects.
39643967
Split the binary sequence into subsequences of the same type, using *sep*
39653968
as the delimiter string. If *maxsplit* is given, at most *maxsplit* splits
39663969
are done, the *rightmost* ones. If *sep* is not specified or ``None``,
3967-
any subsequence consisting solely of ASCII whitespace is a separator.
3970+
any subsequence consisting solely of
3971+
:meth:`ASCII whitespace <bytes.isspace>` is a separator.
39683972
Except for splitting from the right, :meth:`rsplit` behaves like
39693973
:meth:`split` which is described in detail below.
39703974

@@ -3975,7 +3979,8 @@ produce new objects.
39753979
Return a copy of the sequence with specified trailing bytes removed. The
39763980
*bytes* argument is a binary sequence specifying the set of byte values to
39773981
be removed. If omitted or ``None``, the *bytes* argument defaults to
3978-
removing ASCII whitespace. The *bytes* argument is not a suffix; rather,
3982+
removing :meth:`ASCII whitespace <bytes.isspace>`.
3983+
The *bytes* argument is not a suffix; rather,
39793984
all combinations of its values are stripped::
39803985

39813986
>>> b' spacious '.rstrip()
@@ -4028,7 +4033,8 @@ produce new objects.
40284033
[b'1', b'2', b'3<4']
40294034

40304035
If *sep* is not specified or is ``None``, a different splitting algorithm
4031-
is applied: runs of consecutive ASCII whitespace are regarded as a single
4036+
is applied: runs of consecutive :meth:`ASCII whitespace <bytes.isspace>`
4037+
are regarded as a single
40324038
separator, and the result will contain no empty strings at the start or
40334039
end if the sequence has leading or trailing whitespace. Consequently,
40344040
splitting an empty sequence or a sequence consisting solely of ASCII
@@ -4051,7 +4057,8 @@ produce new objects.
40514057
Return a copy of the sequence with specified leading and trailing bytes
40524058
removed. The *bytes* argument is a binary sequence specifying the set of
40534059
byte values to be removed. If omitted or ``None``, the *bytes*
4054-
argument defaults to removing ASCII whitespace. The *bytes* argument is
4060+
argument defaults to removing :meth:`ASCII whitespace <bytes.isspace>`.
4061+
The *bytes* argument is
40554062
not a prefix or suffix; rather, all combinations of its values are
40564063
stripped::
40574064

0 commit comments

Comments
 (0)