Skip to content

Commit 7f26e72

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 4fe5490 commit 7f26e72

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

24312431
Return a list of the words in the string, using *sep* as the delimiter string.
24322432
If *maxsplit* is given, at most *maxsplit* splits are done, the *rightmost*
2433-
ones. If *sep* is not specified or ``None``, any whitespace string is a
2433+
ones. If *sep* is not specified or ``None``, any
2434+
:meth:`whitespace <str.isspace>` string is a
24342435
separator. Except for splitting from the right, :meth:`rsplit` behaves like
24352436
:meth:`split` which is described in detail below.
24362437

@@ -2490,7 +2491,8 @@ expression support in the :mod:`re` module).
24902491
['1', '2', '3<4']
24912492

24922493
If *sep* is not specified or is ``None``, a different splitting algorithm is
2493-
applied: runs of consecutive whitespace are regarded as a single separator,
2494+
applied: runs of consecutive :meth:`whitespace <str.isspace>` are regarded
2495+
as a single separator,
24942496
and the result will contain no empty strings at the start or end if the
24952497
string has leading or trailing whitespace. Consequently, splitting an empty
24962498
string or a string consisting of just whitespace with a ``None`` separator
@@ -3648,7 +3650,8 @@ produce new objects.
36483650
Return a copy of the sequence with specified leading bytes removed. The
36493651
*bytes* argument is a binary sequence specifying the set of byte values to
36503652
be removed. If omitted or ``None``, the *bytes* argument defaults
3651-
to removing ASCII whitespace. The *bytes* argument is not a prefix;
3653+
to removing :meth:`ASCII whitespace <bytes.isspace>`.
3654+
The *bytes* argument is not a prefix;
36523655
rather, all combinations of its values are stripped::
36533656

36543657
>>> b' spacious '.lstrip()
@@ -3692,7 +3695,8 @@ produce new objects.
36923695
Split the binary sequence into subsequences of the same type, using *sep*
36933696
as the delimiter string. If *maxsplit* is given, at most *maxsplit* splits
36943697
are done, the *rightmost* ones. If *sep* is not specified or ``None``,
3695-
any subsequence consisting solely of ASCII whitespace is a separator.
3698+
any subsequence consisting solely of
3699+
:meth:`ASCII whitespace <bytes.isspace>` is a separator.
36963700
Except for splitting from the right, :meth:`rsplit` behaves like
36973701
:meth:`split` which is described in detail below.
36983702

@@ -3703,7 +3707,8 @@ produce new objects.
37033707
Return a copy of the sequence with specified trailing bytes removed. The
37043708
*bytes* argument is a binary sequence specifying the set of byte values to
37053709
be removed. If omitted or ``None``, the *bytes* argument defaults to
3706-
removing ASCII whitespace. The *bytes* argument is not a suffix; rather,
3710+
removing :meth:`ASCII whitespace <bytes.isspace>`.
3711+
The *bytes* argument is not a suffix; rather,
37073712
all combinations of its values are stripped::
37083713

37093714
>>> b' spacious '.rstrip()
@@ -3756,7 +3761,8 @@ produce new objects.
37563761
[b'1', b'2', b'3<4']
37573762

37583763
If *sep* is not specified or is ``None``, a different splitting algorithm
3759-
is applied: runs of consecutive ASCII whitespace are regarded as a single
3764+
is applied: runs of consecutive :meth:`ASCII whitespace <bytes.isspace>`
3765+
are regarded as a single
37603766
separator, and the result will contain no empty strings at the start or
37613767
end if the sequence has leading or trailing whitespace. Consequently,
37623768
splitting an empty sequence or a sequence consisting solely of ASCII
@@ -3779,7 +3785,8 @@ produce new objects.
37793785
Return a copy of the sequence with specified leading and trailing bytes
37803786
removed. The *bytes* argument is a binary sequence specifying the set of
37813787
byte values to be removed. If omitted or ``None``, the *bytes*
3782-
argument defaults to removing ASCII whitespace. The *bytes* argument is
3788+
argument defaults to removing :meth:`ASCII whitespace <bytes.isspace>`.
3789+
The *bytes* argument is
37833790
not a prefix or suffix; rather, all combinations of its values are
37843791
stripped::
37853792

0 commit comments

Comments
 (0)