From 55087002b5ed8b3689ef9e70e61ae56bbbab8441 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Tue, 11 May 2021 20:47:30 -0300 Subject: [PATCH 01/43] [Doc] Added snippet code to str.join method --- Doc/library/stdtypes.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 0caa725f75e642..cc13ff0def5397 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1924,6 +1924,13 @@ expression support in the :mod:`re` module). *iterable*, including :class:`bytes` objects. The separator between elements is the string providing this method. + For example:: + + >>> ', '.join(['spam', 'spam', 'spam']) + 'spam, spam, spam' + >>> '-'.join('Python') + 'P-y-t-h-o-n' + .. method:: str.ljust(width[, fillchar]) From e388d452cf523375c9f9b6b332c385db662c0203 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Tue, 11 May 2021 21:05:50 -0300 Subject: [PATCH 02/43] [Doc] Added snippet code to str.ljust method --- Doc/library/stdtypes.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index cc13ff0def5397..f87f7e407d7830 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1938,6 +1938,14 @@ expression support in the :mod:`re` module). done using the specified *fillchar* (default is an ASCII space). The original string is returned if *width* is less than or equal to ``len(s)``. + For example:: + + >>> 'Python'.ljust(10) + 'Python ' + >>> 'Python'.ljust(10, '.') + 'Python....' + + See also :meth:`rjust`. .. method:: str.lower() From d8407ba676a93ea1e446d2acf48578ffddc1e9d0 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Tue, 11 May 2021 21:09:10 -0300 Subject: [PATCH 03/43] [Doc] Added snippet code to str.rjust method --- Doc/library/stdtypes.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index f87f7e407d7830..c76458d10cd2c9 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2055,6 +2055,14 @@ expression support in the :mod:`re` module). done using the specified *fillchar* (default is an ASCII space). The original string is returned if *width* is less than or equal to ``len(s)``. + For example:: + + >>> 'Python'.rjust(10) + ' Python' + >>> 'Python'.rjust(10, '.') + '....Python' + + See also :meth:`ljust`. .. method:: str.rpartition(sep) From 08b88ef5d66ec4578b326278bd396d8c8f51fc8a Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Tue, 11 May 2021 21:20:30 -0300 Subject: [PATCH 04/43] [Doc] Added 'See also' in str.lstrip and str.rstrip methods from one to the another --- Doc/library/stdtypes.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index c76458d10cd2c9..5c33b5181a77c1 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1977,6 +1977,7 @@ expression support in the :mod:`re` module). >>> 'Arthur: three!'.removeprefix('Arthur: ') 'three!' + See also :meth:`rstrip`. .. staticmethod:: str.maketrans(x[, y[, z]]) @@ -2101,6 +2102,8 @@ expression support in the :mod:`re` module). >>> 'Monty Python'.removesuffix(' Python') 'Monty' + See also :meth:`lstrip`. + .. method:: str.split(sep=None, maxsplit=-1) Return a list of the words in the string, using *sep* as the delimiter From 52e3a6b6df41f51679e1cd26ac637e6b40841dbc Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Tue, 11 May 2021 23:38:28 -0300 Subject: [PATCH 05/43] [Doc] Added snippet code to str.maketrans method --- Doc/library/stdtypes.rst | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 5c33b5181a77c1..7a10235d80c2dc 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1988,11 +1988,20 @@ expression support in the :mod:`re` module). strings (of arbitrary lengths) or ``None``. Character keys will then be converted to ordinals. + For example:: + + >>> str.maketrans({'a': 'A', 'b': 'Boo', 'c': None}) + {97: 'A', 98: 'Boo', 99: None} + If there are two arguments, they must be strings of equal length, and in the - resulting dictionary, each character in x will be mapped to the character at - the same position in y. If there is a third argument, it must be a string, - whose characters will be mapped to ``None`` in the result. + resulting dictionary, each character in *x* will be mapped to the character + at the same position in *y*. If there is a third argument, it must be a + string, whose characters will be mapped to ``None`` in the result. + + For example:: + >>> str.maketrans('ab', 'AB', 'c') + {97: 65, 98: 66, 99: None} .. method:: str.partition(sep) From dee059c3238fa625880e1f509b7583f42fc514e0 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Tue, 11 May 2021 23:53:04 -0300 Subject: [PATCH 06/43] [Doc] Added snippet code to str.translate method --- Doc/library/stdtypes.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 7a10235d80c2dc..0557efb99bf916 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2306,6 +2306,13 @@ expression support in the :mod:`re` module). You can use :meth:`str.maketrans` to create a translation map from character-to-character mappings in different formats. + For example:: + + >>> str.maketrans('to', '70') + {116: 55, 111: 48} + >>> 'Python'.translate({116:55, 111:48}) + 'Py7h0n' + See also the :mod:`codecs` module for a more flexible approach to custom character mappings. From 1671497cb44785775b237fca0f51d1f4a576c31f Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Wed, 12 May 2021 19:29:37 -0300 Subject: [PATCH 07/43] [Doc] Added snippet code to str.partition method --- Doc/library/stdtypes.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 0557efb99bf916..6f553a57d1b4aa 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2010,6 +2010,13 @@ expression support in the :mod:`re` module). after the separator. If the separator is not found, return a 3-tuple containing the string itself, followed by two empty strings. + For example:: + + >>> 'Monty Python'.partition(' ') + ('Monty', ' ', 'Python') + >>> 'Monty Python'.partition('-') + ('Monty Python', '', '') + .. method:: str.removeprefix(prefix, /) From c832623a5664dc501d7b00fb99edf8e35cc54af5 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Wed, 12 May 2021 19:35:29 -0300 Subject: [PATCH 08/43] [Doc] Added snippet code to str.replace method --- Doc/library/stdtypes.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 6f553a57d1b4aa..6c109139727822 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2052,6 +2052,12 @@ expression support in the :mod:`re` module). *new*. If the optional argument *count* is given, only the first *count* occurrences are replaced. + For example:: + + >>> 'spam, spam, spam'.replace('spam', 'eggs') + 'eggs, eggs, eggs' + >>> 'spam, spam, spam'.replace('spam', 'eggs', 1) + 'eggs, spam, spam' .. method:: str.rfind(sub[, start[, end]]) From 0be8170781b653cb2e6bda4b82135ee138934c39 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Wed, 12 May 2021 19:45:57 -0300 Subject: [PATCH 09/43] [Doc] Added snippet code to str.rfind method --- Doc/library/stdtypes.rst | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 6c109139727822..90ea5a6e5bd2dc 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1722,7 +1722,15 @@ expression support in the :mod:`re` module). Return the lowest index in the string where substring *sub* is found within the slice ``s[start:end]``. Optional arguments *start* and *end* are - interpreted as in slice notation. Return ``-1`` if *sub* is not found. + interpreted as in slice notation. Return ``-1`` if *sub* is not found. For + example:: + + >>> 'spam, spam, spam'.find('sp') + 0 + >>> 'spam, spam, spam'.find('sp', 5) + 6 + + See also :meth:`rfind`. .. note:: @@ -2065,6 +2073,14 @@ expression support in the :mod:`re` module). that *sub* is contained within ``s[start:end]``. Optional arguments *start* and *end* are interpreted as in slice notation. Return ``-1`` on failure. + For example:: + + >>> 'spam, spam, spam'.rfind('sp') + 12 + >>> 'spam, spam, spam'.rfind('sp', 0, 10) + 6 + + See also :meth:`find`. .. method:: str.rindex(sub[, start[, end]]) From ff65bd28953911ab1c4a10cf53ac077b6aa2d982 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Wed, 12 May 2021 19:55:24 -0300 Subject: [PATCH 10/43] [Doc] Added snippet code to str.rindex method --- Doc/library/stdtypes.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 90ea5a6e5bd2dc..f662368fbcb587 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1795,6 +1795,9 @@ expression support in the :mod:`re` module). not found. + See also :meth:`rindex`. + + .. method:: str.isalnum() Return ``True`` if all characters in the string are alphanumeric and there is at @@ -2087,6 +2090,14 @@ expression support in the :mod:`re` module). Like :meth:`rfind` but raises :exc:`ValueError` when the substring *sub* is not found. + For example:: + + >>> 'spam, spam, spam'.rindex('eggs') + Traceback (most recent call last): + File "", line 1, in + ValueError: substring not found + + See also :meth:`index`. .. method:: str.rjust(width[, fillchar]) From 322c88c6f2fb5a3489ebdabd7e91e70c52e4215a Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Wed, 12 May 2021 20:05:59 -0300 Subject: [PATCH 11/43] [Doc] Added snippet code to str.rpartition method --- Doc/library/stdtypes.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index f662368fbcb587..4eb866c009bfd8 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2028,6 +2028,7 @@ expression support in the :mod:`re` module). >>> 'Monty Python'.partition('-') ('Monty Python', '', '') + See also :meth:`rpartition` .. method:: str.removeprefix(prefix, /) @@ -2121,6 +2122,12 @@ expression support in the :mod:`re` module). after the separator. If the separator is not found, return a 3-tuple containing two empty strings, followed by the string itself. + For example:: + + >>> "Monty Python's Flying Circus".rpartition(' ') + ("Monty Python's Flying", ' ', 'Circus') + + See also :meth:`partition` .. method:: str.rsplit(sep=None, maxsplit=-1) From 3a473df6d65d2551709e0ae59ac73e6e744c01ca Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Wed, 12 May 2021 20:14:57 -0300 Subject: [PATCH 12/43] [DOC] minor change --- Doc/library/stdtypes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 4eb866c009bfd8..8766a0e907811e 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2127,7 +2127,7 @@ expression support in the :mod:`re` module). >>> "Monty Python's Flying Circus".rpartition(' ') ("Monty Python's Flying", ' ', 'Circus') - See also :meth:`partition` + See also :meth:`partition`. .. method:: str.rsplit(sep=None, maxsplit=-1) From b6536934c56bab852b8ae5c697127ea32feb35f8 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Wed, 12 May 2021 20:19:00 -0300 Subject: [PATCH 13/43] [Doc] Added snippet code to str.rsplit method --- Doc/library/stdtypes.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 8766a0e907811e..bb0633130e94ca 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2137,6 +2137,10 @@ expression support in the :mod:`re` module). separator. Except for splitting from the right, :meth:`rsplit` behaves like :meth:`split` which is described in detail below. + For example:: + + >>> '1,2,3'.rsplit(',', maxsplit=1) + ['1,2', '3'] .. method:: str.rstrip([chars]) @@ -2199,6 +2203,7 @@ expression support in the :mod:`re` module). >>> ' 1 2 3 '.split() ['1', '2', '3'] + See also :meth:`rsplit`. .. index:: single: universal newlines; str.splitlines method From 1b412cb6d936f40b14a7afa628c92a91699e1ee8 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Wed, 12 May 2021 20:30:42 -0300 Subject: [PATCH 14/43] [Doc] Added snippet code to str.startswith method --- Doc/library/stdtypes.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index bb0633130e94ca..4725707faf2bf8 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1696,6 +1696,7 @@ expression support in the :mod:`re` module). *start*, test beginning at that position. With optional *end*, stop comparing at that position. + See also :meth:`startswith`. .. method:: str.expandtabs(tabsize=8) @@ -2278,6 +2279,18 @@ expression support in the :mod:`re` module). test string beginning at that position. With optional *end*, stop comparing string at that position. + For example: + + >>> 'Python'.startswith('Py') + True + >>> 'a tuple of prefixes'.startswith(('at', 'in')) + False + >>> 'a tuple of suffixes'.startswith(('at', 'a')) + True + >>> 'Python is amazing'.startswith('is', 7) + True + + See also :meth:`endswith`. .. method:: str.strip([chars]) From fb56441769ea97e0eb0b443584582380aee9974b Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Wed, 12 May 2021 20:55:33 -0300 Subject: [PATCH 15/43] [Doc] Added snippet code to str.swapcase method --- Doc/library/stdtypes.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 4725707faf2bf8..ac8caf576caf7b 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2322,6 +2322,12 @@ expression support in the :mod:`re` module). vice versa. Note that it is not necessarily true that ``s.swapcase().swapcase() == s``. + For example:: + + >>> 'Monty Python'.swapcase() + 'mONTY pYTHON' + + See also :meth:`upper` and :meth:`lower`. .. method:: str.title() From 04a5212ee027256418c2bf4c6304a47ae3a3610d Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Wed, 12 May 2021 22:07:53 -0300 Subject: [PATCH 16/43] [Doc] Added snippet code to str.upper method --- Doc/library/stdtypes.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index ac8caf576caf7b..a833ef880d23f4 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1968,6 +1968,13 @@ expression support in the :mod:`re` module). `described in section 3.13 'Default Case Folding' of the Unicode Standard `__. +<<<<<<< HEAD +======= + The lowercasing algorithm used is described in section 3.13 of the Unicode + Standard. + + See also :meth:`casefold`, :meth:`swapcase` and :meth:`upper`. +>>>>>>> 58b11f169d ([Doc] Added snippet code to str.upper method) .. method:: str.lstrip([chars]) @@ -2396,10 +2403,18 @@ expression support in the :mod:`re` module). character(s) is not "Lu" (Letter, uppercase), but e.g. "Lt" (Letter, titlecase). + For example:: + + >>> 'Monty Python'.upper() + 'MONTY PYTHON' + >>> '𐊠'.upper().isupper() # 'CARIAN LETTER A' + False + The uppercasing algorithm used is `described in section 3.13 'Default Case Folding' of the Unicode Standard `__. + See also :meth:`swapcase` and :meth:`lower`. .. method:: str.zfill(width) From 8771775c4ad6b7ab26322e16624c97927238e43c Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sat, 27 Feb 2021 20:09:10 -0300 Subject: [PATCH 17/43] [DOC] Added snipped code in str.capitalize --- Doc/library/stdtypes.rst | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index a833ef880d23f4..5d0858c1a46006 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1619,13 +1619,21 @@ expression support in the :mod:`re` module). .. method:: str.capitalize() Return a copy of the string with its first character capitalized and the - rest lowercased. + rest lowercased. For example:: + + >>> 'PYTHON IS AMAZING'.capitalize() + 'Python is amazing' + >>> 'Njemačka Starts With a non-english Digraph'.capitalize() + 'Njemačka starts with a non-english digraph' + + See also :meth:`title`. .. versionchanged:: 3.8 The first character is now put into titlecase rather than uppercase. This means that characters like digraphs will only have their first letter capitalized, instead of the full character. + .. method:: str.casefold() Return a casefolded copy of the string. Casefolded strings may be used for @@ -1991,7 +1999,7 @@ expression support in the :mod:`re` module). See :meth:`str.removeprefix` for a method that will remove a single prefix string rather than all of a set of characters. For example:: - >>> 'Arthur: three!'.lstrip('Arthur: ') + >>> 'Arthur: three!'.lstrip('Arthur: ' 'ee!' >>> 'Arthur: three!'.removeprefix('Arthur: ') 'three!' From f2e224c8b782cef39fac13c70359c2ecebb716b5 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sat, 27 Feb 2021 20:27:04 -0300 Subject: [PATCH 18/43] [DOC] Add snippet code in str.casefold and str.lower methods --- Doc/library/stdtypes.rst | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 5d0858c1a46006..649e66fe0931a2 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1643,7 +1643,12 @@ expression support in the :mod:`re` module). intended to remove all case distinctions in a string. For example, the German lowercase letter ``'ß'`` is equivalent to ``"ss"``. Since it is already lowercase, :meth:`lower` would do nothing to ``'ß'``; :meth:`casefold` - converts it to ``"ss"``. + converts it to ``"ss"``, as follows:: + + >>> 'ß'.casefold() + 'ss' + >>> 'ß'.lower() + 'ß' The casefolding algorithm is `described in section 3.13 'Default Case Folding' of the Unicode Standard @@ -1970,20 +1975,15 @@ expression support in the :mod:`re` module). .. method:: str.lower() Return a copy of the string with all the cased characters [4]_ converted to - lowercase. + lowercase. For example:: + + >>> 'Lower Method Example'.lower() + 'lower method example' The lowercasing algorithm used is `described in section 3.13 'Default Case Folding' of the Unicode Standard `__. -<<<<<<< HEAD -======= - The lowercasing algorithm used is described in section 3.13 of the Unicode - Standard. - - See also :meth:`casefold`, :meth:`swapcase` and :meth:`upper`. ->>>>>>> 58b11f169d ([Doc] Added snippet code to str.upper method) - .. method:: str.lstrip([chars]) Return a copy of the string with leading characters removed. The *chars* From 1d39f927a655f8b126a95c43db2d4014cb9bd939 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sat, 27 Feb 2021 20:36:28 -0300 Subject: [PATCH 19/43] [DOC] Added snippet code in str.center method --- Doc/library/stdtypes.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 649e66fe0931a2..9863d964b4b986 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1661,8 +1661,14 @@ expression support in the :mod:`re` module). Return centered in a string of length *width*. Padding is done using the specified *fillchar* (default is an ASCII space). The original string is - returned if *width* is less than or equal to ``len(s)``. - + returned if *width* is less than or equal to ``len(s)``. For example:: + + >>> 'Python'.center(10) + ' Python ' + >>> 'Python'.center(10, '-') + '--Python--' + >>> 'Python'.center(4) + 'Python' .. method:: str.count(sub[, start[, end]]) From b3a70b625bd083d1375d8567c0a6c538875fc2b3 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sat, 27 Feb 2021 20:52:46 -0300 Subject: [PATCH 20/43] [DOC] Added snippet code in str.count method --- Doc/library/stdtypes.rst | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 9863d964b4b986..a3169c8e31b35c 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1675,11 +1675,23 @@ expression support in the :mod:`re` module). Return the number of non-overlapping occurrences of substring *sub* in the range [*start*, *end*]. Optional arguments *start* and *end* are - interpreted as in slice notation. + interpreted as in slice notation. If *sub* is empty, returns the number of empty strings between characters which is the length of the string plus one. + For example:: + + >>> 'spam, spam, spam'.count('spam') + 3 + >>> 'spam, spam, spam'.count('spam', 5) + 2 + >>> 'spam, spam, spam'.count('spam', 5, 10) + 1 + >>> 'spam, spam, spam'.count('eggs') + 0 + >>> 'spam, spam, spam'.count('') + 17 .. method:: str.encode(encoding="utf-8", errors="strict") From 37477f87e19b368f6e0dde907ddffa6072d64fa5 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sat, 27 Feb 2021 21:41:09 -0300 Subject: [PATCH 21/43] [DOC] fix typo --- Doc/library/stdtypes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index a3169c8e31b35c..98ad318de65e21 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2017,7 +2017,7 @@ expression support in the :mod:`re` module). See :meth:`str.removeprefix` for a method that will remove a single prefix string rather than all of a set of characters. For example:: - >>> 'Arthur: three!'.lstrip('Arthur: ' + >>> 'Arthur: three!'.lstrip('Arthur: ') 'ee!' >>> 'Arthur: three!'.removeprefix('Arthur: ') 'three!' From f9a7293e362661dd8e40de3fbac3b8636b6d7dcd Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sat, 13 Mar 2021 19:10:57 -0300 Subject: [PATCH 22/43] [DOC] Added snippet code in str.encode method --- Doc/library/stdtypes.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 98ad318de65e21..be2b2f78b8d3ed 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1712,6 +1712,14 @@ expression support in the :mod:`re` module). :ref:`devmode` is enabled or a :ref:`debug build ` is used. + For example:: + + >>> encoded_str_to_byte = 'Python'.encode() + >>> type(encoded_str_to_byte) + + >>> encoded_str_to_byte + b'Python' + .. versionchanged:: 3.1 Added support for keyword arguments. From 2e54cb02fb8b2f20c0b7f61373a7b7c8b13a2173 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sat, 13 Mar 2021 19:32:55 -0300 Subject: [PATCH 23/43] [DOC] Added snippet code to str.endswith method --- Doc/library/stdtypes.rst | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index be2b2f78b8d3ed..d844a31d2d6f34 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1733,7 +1733,17 @@ expression support in the :mod:`re` module). Return ``True`` if the string ends with the specified *suffix*, otherwise return ``False``. *suffix* can also be a tuple of suffixes to look for. With optional *start*, test beginning at that position. With optional *end*, stop comparing - at that position. + at that position. Use the *start* and *end* is equivalent to + ``str[start:end].endswith(suffix)``. For example:: + + >>> 'Python'.endswith('on') + True + >>> 'a tuple of suffixes'.endswith(('at', 'in')) + False + >>> 'a tuple of suffixes'.endswith(('at', 'es')) + True + >>> 'Python is amazing'.endswith('is', 0, 9) + True See also :meth:`startswith`. From 96d9bf6ba2f40f6ed83e45bd7f623e98b87bca0a Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sat, 13 Mar 2021 19:40:21 -0300 Subject: [PATCH 24/43] [DOC] Added snippet code with \n to str.expandtabs method --- Doc/library/stdtypes.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index d844a31d2d6f34..2c61a1892659b2 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1766,6 +1766,10 @@ expression support in the :mod:`re` module). '01 012 0123 01234' >>> '01\t012\t0123\t01234'.expandtabs(4) '01 012 0123 01234' + >>> print('01\t012\n0123\t01234'.expandtabs(4)) + 01 012 + 0123 01234 + .. method:: str.find(sub[, start[, end]]) From d1dc7e058c9a5a08ad8f148892f39638463ea584 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sun, 14 Mar 2021 20:37:58 -0300 Subject: [PATCH 25/43] [DOC] Added snippet code to str.index method --- Doc/library/stdtypes.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 2c61a1892659b2..39fd4b7cb9ede2 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1848,6 +1848,12 @@ expression support in the :mod:`re` module). Like :meth:`~str.find`, but raise :exc:`ValueError` when the substring is not found. + For example:: + + >>> 'spam, spam, spam'.index('eggs') + Traceback (most recent call last): + File "", line 1, in + ValueError: substring not found See also :meth:`rindex`. From 8661d8e6703b5c809f23dcdb67186fdfe172b45a Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sun, 14 Mar 2021 20:41:35 -0300 Subject: [PATCH 26/43] [DOC] Added snippet code to str.isalnum method --- Doc/library/stdtypes.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 39fd4b7cb9ede2..5df364b002056c 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1865,6 +1865,16 @@ expression support in the :mod:`re` module). of the following returns ``True``: ``c.isalpha()``, ``c.isdecimal()``, ``c.isdigit()``, or ``c.isnumeric()``. + For example:: + + >>> ''.isalnum() + False + >>> 'abc123'.isalnum() + True + >>> 'abc123!@#'.isalnum() + False + >>> ' '.isalnum() + False .. method:: str.isalpha() From 9e1f289acb63eab08b33df2c05719d14c62a96c1 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sun, 14 Mar 2021 22:51:39 -0300 Subject: [PATCH 27/43] [DOC] Added snippet code in str.isalpha method --- Doc/library/stdtypes.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 5df364b002056c..f3d7ab3e8b016f 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1886,6 +1886,20 @@ expression support in the :mod:`re` module). Ideographic' of the Unicode Standard `_. + For example:: + + >>> 'a commom word'.isalpha() + False + >>> 'acommomword'.isalpha() + True + >>> 'µ'.isalpha() + True + >>> 'æ'.isalpha() + True + >>> 'Ŧ'.isalpha() + True + + See Unicode Properties section in :ref:`unicode-howto`. .. method:: str.isascii() From 9e361d8d04bf19e08837b4c9716038d79adbbe60 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sun, 14 Mar 2021 23:17:08 -0300 Subject: [PATCH 28/43] [DOC] Added snippet code in str.isascii method --- Doc/library/stdtypes.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index f3d7ab3e8b016f..835f134056c380 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1907,6 +1907,19 @@ expression support in the :mod:`re` module). ``False`` otherwise. ASCII characters have code points in the range U+0000-U+007F. + For example:: + + >>> 'a commom word'.isascii() + True + >>> 'acommomword'.isascii() + True + >>> 'µ'.isascii() + False + >>> 'æ'.isascii() + False + >>> 'Ŧ'.isascii() + False + .. versionadded:: 3.7 From 09a463a740214d16555b4388858c2b79f3870c0b Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sun, 14 Mar 2021 23:46:08 -0300 Subject: [PATCH 29/43] [DOC] Added snippet code to str.isdecimal method --- Doc/library/stdtypes.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 835f134056c380..ab7e4d1adc13e4 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1932,6 +1932,12 @@ expression support in the :mod:`re` module). ZERO. Formally a decimal character is a character in the Unicode General Category "Nd". + For example:: + + >>> '0123456789'.isdecimal() + True + >>> '٠١٢٣٤٥٦٧٨٩'.isdecimal() #ARABIC-INDIC DIGIT ZERO TO NINE + True .. method:: str.isdigit() @@ -1942,7 +1948,6 @@ expression support in the :mod:`re` module). like the Kharosthi numbers. Formally, a digit is a character that has the property value Numeric_Type=Digit or Numeric_Type=Decimal. - .. method:: str.isidentifier() Return ``True`` if the string is a valid identifier according to the language From 641de5ce904de81cbe29f97e4b6e82624d7604db Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sun, 21 Mar 2021 22:06:20 -0300 Subject: [PATCH 30/43] [Doc] Added snippet code to str.isdigit method --- Doc/library/stdtypes.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index ab7e4d1adc13e4..c882c65b62825a 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1938,6 +1938,10 @@ expression support in the :mod:`re` module). True >>> '٠١٢٣٤٥٦٧٨٩'.isdecimal() #ARABIC-INDIC DIGIT ZERO TO NINE True + >>> '²'.isdecimal(), '²'.isdigit() + (False, True) + + See also :meth:`isdigit`. Decimal numbers is a digit numbers subset. .. method:: str.isdigit() @@ -1948,6 +1952,17 @@ expression support in the :mod:`re` module). like the Kharosthi numbers. Formally, a digit is a character that has the property value Numeric_Type=Digit or Numeric_Type=Decimal. + For example:: + + >>> '0123456789'.isdigit() + True + >>> '٠١٢٣٤٥٦٧٨٩'.isdigit() #ARABIC-INDIC DIGIT ZERO TO NINE + True + >>> '²'.isdigit(), '²'.isdecimal() + (True, False) + + See also :meth:`isdecimal`. Digit numbers is a decimal numbers superset. + .. method:: str.isidentifier() Return ``True`` if the string is a valid identifier according to the language From eae1564c842e4d8bee88d5f137158375a60adae4 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sun, 21 Mar 2021 22:21:52 -0300 Subject: [PATCH 31/43] [Doc] Added snippet code to str.islower method --- Doc/library/stdtypes.rst | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index c882c65b62825a..b6e39238ad89fa 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1987,6 +1987,20 @@ expression support in the :mod:`re` module). Return ``True`` if all cased characters [4]_ in the string are lowercase and there is at least one cased character, ``False`` otherwise. + For example:: + + >>> 'BANANA'.islower() + False + >>> 'banana'.islower() + True + >>> 'baNana'.islower() + False + >>> ' '.islower() + False + >>> ''.islower() + False + + See also :meth:`isupper`. .. method:: str.isnumeric() @@ -2040,8 +2054,10 @@ expression support in the :mod:`re` module). False >>> ' '.isupper() False + >>> ''.isupper() + False - + See also :meth:`islower`. .. _meth-str-join: From 58331b8c7607bdec2365c798dd88c3cf3c78cee5 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sun, 21 Mar 2021 22:35:52 -0300 Subject: [PATCH 32/43] [Doc] Added snippet code to str.isnumeric method --- Doc/library/stdtypes.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index b6e39238ad89fa..9b07b5b6cdbbae 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2011,6 +2011,20 @@ expression support in the :mod:`re` module). VULGAR FRACTION ONE FIFTH. Formally, numeric characters are those with the property value Numeric_Type=Digit, Numeric_Type=Decimal or Numeric_Type=Numeric. + For example:: + + >>> '0123456789'.isnumeric() + True + >>> '٠١٢٣٤٥٦٧٨٩'.isnumeric() #ARABIC-INDIC DIGIT ZERO TO NINE + True + >>> '⅕'.isnumeric() # VULGAR FRACTION ONE FIFTH + True + >>> '²'.isdigit(), '²'.isdecimal(), '²'.isnumeric() + (True, False, True) + + See also :meth:`isdecimal` and :meth:`isdigit`. Numeric characters is a + decimal numbers superset. + .. method:: str.isprintable() From d7ce39c9ccdac9ee489875659a05fea6e5d651f7 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sun, 21 Mar 2021 22:55:05 -0300 Subject: [PATCH 33/43] [Doc] Added snippet code to str.isprintable method --- Doc/library/stdtypes.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 9b07b5b6cdbbae..5fe99b3f775948 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2036,6 +2036,15 @@ expression support in the :mod:`re` module). :func:`repr` is invoked on a string. It has no bearing on the handling of strings written to :data:`sys.stdout` or :data:`sys.stderr`.) + For example:: + + >>> ''.isprintable() + True + >>> ' '.isprintable() + True + >>> '\t\n'.isprintable() # TAB and BREAK LINE + False + .. method:: str.isspace() From b86cefd6b0366d08c9551b25b1cce44aa23cb47b Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sun, 21 Mar 2021 23:31:07 -0300 Subject: [PATCH 34/43] [Doc] Added snippet code to str.isspace method --- Doc/library/stdtypes.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 5fe99b3f775948..c0cc221f354cac 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2044,7 +2044,10 @@ expression support in the :mod:`re` module). True >>> '\t\n'.isprintable() # TAB and BREAK LINE False + >>> '\u3000'.isprintable() # IDEOGRAPHIC SPACE + False + See also :meth:`isspace`. .. method:: str.isspace() @@ -2056,6 +2059,18 @@ expression support in the :mod:`re` module). ("Separator, space"), or its bidirectional class is one of ``WS``, ``B``, or ``S``. + For example:: + + >>> ''.isspace() + False + >>> ' '.isspace() + True + >>> '\t\n'.isspace() # TAB and BREAK LINE + True + >>> '\u3000'.isspace() # IDEOGRAPHIC SPACE + True + + See also :meth:`isprintable`. .. method:: str.istitle() From 3df630cae07f3cea513d8fb6670912c76156602e Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sun, 21 Mar 2021 23:42:19 -0300 Subject: [PATCH 35/43] [Doc] Adde snippet code to str.istitle method --- Doc/library/stdtypes.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index c0cc221f354cac..b3c493a0099e97 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2078,6 +2078,16 @@ expression support in the :mod:`re` module). character, for example uppercase characters may only follow uncased characters and lowercase characters only cased ones. Return ``False`` otherwise. + For example:: + + >>> 'Spam, Spam, Spam'.istitle() + True + >>> 'spam, spam, spam'.istitle() + False + >>> 'SPAM, SPAM, SPAM'.istitle() + False + + See also :meth:`title`. .. method:: str.isupper() @@ -2534,6 +2544,7 @@ expression support in the :mod:`re` module). >>> titlecase("they're bill's friends.") "They're Bill's Friends." + See also :meth:`istitle`. .. method:: str.translate(table) From ae42fead84b96bbdb3ecdd9ed75f1da18b8866bb Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sun, 11 Jun 2023 21:01:12 +0100 Subject: [PATCH 36/43] Minor changes (formatting and typo) --- Doc/library/stdtypes.rst | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index b3c493a0099e97..85eab17ee6a087 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1693,6 +1693,7 @@ expression support in the :mod:`re` module). >>> 'spam, spam, spam'.count('') 17 + .. method:: str.encode(encoding="utf-8", errors="strict") Return the string encoded to :class:`bytes`. @@ -1747,6 +1748,7 @@ expression support in the :mod:`re` module). See also :meth:`startswith`. + .. method:: str.expandtabs(tabsize=8) Return a copy of the string where all tab characters are replaced by one or @@ -1771,7 +1773,6 @@ expression support in the :mod:`re` module). 0123 01234 - .. method:: str.find(sub[, start[, end]]) Return the lowest index in the string where substring *sub* is found within @@ -1876,6 +1877,7 @@ expression support in the :mod:`re` module). >>> ' '.isalnum() False + .. method:: str.isalpha() Return ``True`` if all characters in the string are alphabetic and there is at least @@ -1901,6 +1903,7 @@ expression support in the :mod:`re` module). See Unicode Properties section in :ref:`unicode-howto`. + .. method:: str.isascii() Return ``True`` if the string is empty or all characters in the string are ASCII, @@ -1943,6 +1946,7 @@ expression support in the :mod:`re` module). See also :meth:`isdigit`. Decimal numbers is a digit numbers subset. + .. method:: str.isdigit() Return ``True`` if all characters in the string are digits and there is at least one @@ -1963,6 +1967,7 @@ expression support in the :mod:`re` module). See also :meth:`isdecimal`. Digit numbers is a decimal numbers superset. + .. method:: str.isidentifier() Return ``True`` if the string is a valid identifier according to the language @@ -2002,6 +2007,7 @@ expression support in the :mod:`re` module). See also :meth:`isupper`. + .. method:: str.isnumeric() Return ``True`` if all characters in the string are numeric @@ -2049,6 +2055,7 @@ expression support in the :mod:`re` module). See also :meth:`isspace`. + .. method:: str.isspace() Return ``True`` if there are only whitespace characters in the string and there is @@ -2072,6 +2079,7 @@ expression support in the :mod:`re` module). See also :meth:`isprintable`. + .. method:: str.istitle() Return ``True`` if the string is a titlecased string and there is at least one @@ -2089,6 +2097,7 @@ expression support in the :mod:`re` module). See also :meth:`title`. + .. method:: str.isupper() Return ``True`` if all cased characters [4]_ in the string are uppercase and @@ -2107,6 +2116,7 @@ expression support in the :mod:`re` module). See also :meth:`islower`. + .. _meth-str-join: .. method:: str.join(iterable) @@ -2139,6 +2149,7 @@ expression support in the :mod:`re` module). See also :meth:`rjust`. + .. method:: str.lower() Return a copy of the string with all the cased characters [4]_ converted to @@ -2151,6 +2162,7 @@ expression support in the :mod:`re` module). `described in section 3.13 'Default Case Folding' of the Unicode Standard `__. + .. method:: str.lstrip([chars]) Return a copy of the string with leading characters removed. The *chars* @@ -2173,6 +2185,7 @@ expression support in the :mod:`re` module). See also :meth:`rstrip`. + .. staticmethod:: str.maketrans(x[, y[, z]]) This static method returns a translation table usable for :meth:`str.translate`. @@ -2197,6 +2210,7 @@ expression support in the :mod:`re` module). >>> str.maketrans('ab', 'AB', 'c') {97: 65, 98: 66, 99: None} + .. method:: str.partition(sep) Split the string at the first occurrence of *sep*, and return a 3-tuple @@ -2211,7 +2225,8 @@ expression support in the :mod:`re` module). >>> 'Monty Python'.partition('-') ('Monty Python', '', '') - See also :meth:`rpartition` + See also :meth:`rpartition`. + .. method:: str.removeprefix(prefix, /) @@ -2254,6 +2269,7 @@ expression support in the :mod:`re` module). >>> 'spam, spam, spam'.replace('spam', 'eggs', 1) 'eggs, spam, spam' + .. method:: str.rfind(sub[, start[, end]]) Return the highest index in the string where substring *sub* is found, such @@ -2269,6 +2285,7 @@ expression support in the :mod:`re` module). See also :meth:`find`. + .. method:: str.rindex(sub[, start[, end]]) Like :meth:`rfind` but raises :exc:`ValueError` when the substring *sub* is not @@ -2283,6 +2300,7 @@ expression support in the :mod:`re` module). See also :meth:`index`. + .. method:: str.rjust(width[, fillchar]) Return the string right justified in a string of length *width*. Padding is @@ -2298,6 +2316,7 @@ expression support in the :mod:`re` module). See also :meth:`ljust`. + .. method:: str.rpartition(sep) Split the string at the last occurrence of *sep*, and return a 3-tuple @@ -2312,6 +2331,7 @@ expression support in the :mod:`re` module). See also :meth:`partition`. + .. method:: str.rsplit(sep=None, maxsplit=-1) Return a list of the words in the string, using *sep* as the delimiter string. @@ -2325,6 +2345,7 @@ expression support in the :mod:`re` module). >>> '1,2,3'.rsplit(',', maxsplit=1) ['1,2', '3'] + .. method:: str.rstrip([chars]) Return a copy of the string with trailing characters removed. The *chars* @@ -2347,6 +2368,7 @@ expression support in the :mod:`re` module). See also :meth:`lstrip`. + .. method:: str.split(sep=None, maxsplit=-1) Return a list of the words in the string, using *sep* as the delimiter @@ -2388,6 +2410,7 @@ expression support in the :mod:`re` module). See also :meth:`rsplit`. + .. index:: single: universal newlines; str.splitlines method @@ -2474,6 +2497,7 @@ expression support in the :mod:`re` module). See also :meth:`endswith`. + .. method:: str.strip([chars]) Return a copy of the string with the leading and trailing characters removed. @@ -2511,6 +2535,7 @@ expression support in the :mod:`re` module). See also :meth:`upper` and :meth:`lower`. + .. method:: str.title() Return a titlecased version of the string where words start with an uppercase @@ -2546,6 +2571,7 @@ expression support in the :mod:`re` module). See also :meth:`istitle`. + .. method:: str.translate(table) Return a copy of the string in which each character has been mapped through @@ -2592,6 +2618,7 @@ expression support in the :mod:`re` module). See also :meth:`swapcase` and :meth:`lower`. + .. method:: str.zfill(width) Return a copy of the string left filled with ASCII ``'0'`` digits to @@ -2608,7 +2635,6 @@ expression support in the :mod:`re` module). '-0042' - .. _old-string-formatting: ``printf``-style String Formatting From 4676daaae2251db48c0af65b112796718bcf9850 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sun, 11 Jun 2023 21:41:49 +0100 Subject: [PATCH 37/43] [Doc] Making lint happy --- Doc/library/stdtypes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 85eab17ee6a087..f18fad057cd46d 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1675,7 +1675,7 @@ expression support in the :mod:`re` module). Return the number of non-overlapping occurrences of substring *sub* in the range [*start*, *end*]. Optional arguments *start* and *end* are - interpreted as in slice notation. + interpreted as in slice notation. If *sub* is empty, returns the number of empty strings between characters which is the length of the string plus one. From de11c933a9b4fdc0479b986f2907d8a3b2e1887b Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Mon, 3 Jul 2023 10:25:48 +0100 Subject: [PATCH 38/43] Update Doc/library/stdtypes.rst Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> --- Doc/library/stdtypes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 8674b01fc683a1..aca418d1afeb3e 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1939,7 +1939,7 @@ expression support in the :mod:`re` module). >>> '0123456789'.isdecimal() True - >>> '٠١٢٣٤٥٦٧٨٩'.isdecimal() #ARABIC-INDIC DIGIT ZERO TO NINE + >>> '٠١٢٣٤٥٦٧٨٩'.isdecimal() # ARABIC-INDIC DIGIT ZERO TO NINE True >>> '²'.isdecimal(), '²'.isdigit() (False, True) From 1695b93d3087740ee6add78cf6491eafb343b0fe Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Mon, 3 Jul 2023 10:48:14 +0100 Subject: [PATCH 39/43] [DOC] Added some 'see also' to str methods --- Doc/library/stdtypes.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index aca418d1afeb3e..ddb4e36604da02 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1746,7 +1746,7 @@ expression support in the :mod:`re` module). >>> 'Python is amazing'.endswith('is', 0, 9) True - See also :meth:`startswith`. + See also :meth:`startswith` and :meth:`removesuffix`. .. method:: str.expandtabs(tabsize=8) @@ -1785,7 +1785,7 @@ expression support in the :mod:`re` module). >>> 'spam, spam, spam'.find('sp', 5) 6 - See also :meth:`rfind`. + See also :meth:`rfind` and :meth:`index`. .. note:: @@ -2495,7 +2495,7 @@ expression support in the :mod:`re` module). >>> 'Python is amazing'.startswith('is', 7) True - See also :meth:`endswith`. + See also :meth:`endswith` and :meth:`removeprefix`. .. method:: str.strip([chars]) From ad6b56bbb7d857b268a1ea012c9d923ee8e0426d Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Mon, 3 Jul 2023 11:36:22 +0100 Subject: [PATCH 40/43] [DOC] Moved 'For example' to the end of the previous paragraph --- Doc/library/stdtypes.rst | 153 ++++++++++++--------------------------- 1 file changed, 47 insertions(+), 106 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index ddb4e36604da02..4d7c642e883c62 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1643,7 +1643,7 @@ expression support in the :mod:`re` module). intended to remove all case distinctions in a string. For example, the German lowercase letter ``'ß'`` is equivalent to ``"ss"``. Since it is already lowercase, :meth:`lower` would do nothing to ``'ß'``; :meth:`casefold` - converts it to ``"ss"``, as follows:: + converts it to ``"ss"``, as follows. For example:: >>> 'ß'.casefold() 'ss' @@ -1678,9 +1678,7 @@ expression support in the :mod:`re` module). interpreted as in slice notation. If *sub* is empty, returns the number of empty strings between characters - which is the length of the string plus one. - - For example:: + which is the length of the string plus one. For example:: >>> 'spam, spam, spam'.count('spam') 3 @@ -1711,9 +1709,7 @@ expression support in the :mod:`re` module). For performance reasons, the value of *errors* is not checked for validity unless an encoding error actually occurs, :ref:`devmode` is enabled - or a :ref:`debug build ` is used. - - For example:: + or a :ref:`debug build ` is used. For example:: >>> encoded_str_to_byte = 'Python'.encode() >>> type(encoded_str_to_byte) @@ -1762,7 +1758,7 @@ expression support in the :mod:`re` module). (``\n``) or return (``\r``), it is copied and the current column is reset to zero. Any other character is copied unchanged and the current column is incremented by one regardless of how the character is represented when - printed. + printed. For example:: >>> '01\t012\t0123\t01234'.expandtabs() '01 012 0123 01234' @@ -1791,7 +1787,7 @@ expression support in the :mod:`re` module). The :meth:`~str.find` method should be used only if you need to know the position of *sub*. To check if *sub* is a substring or not, use the - :keyword:`in` operator:: + :keyword:`in` operator. For example:: >>> 'Py' in 'Python' True @@ -1804,7 +1800,7 @@ expression support in the :mod:`re` module). ``{}``. Each replacement field contains either the numeric index of a positional argument, or the name of a keyword argument. Returns a copy of the string where each replacement field is replaced with the string value of - the corresponding argument. + the corresponding argument. For example:: >>> "The sum of 1 + 2 is {0}".format(1+2) 'The sum of 1 + 2 is 3' @@ -1832,7 +1828,7 @@ expression support in the :mod:`re` module). Similar to ``str.format(**mapping)``, except that ``mapping`` is used directly and not copied to a :class:`dict`. This is useful - if for example ``mapping`` is a dict subclass: + if for example ``mapping`` is a dict subclass. For example:: >>> class Default(dict): ... def __missing__(self, key): @@ -1847,9 +1843,7 @@ expression support in the :mod:`re` module). .. method:: str.index(sub[, start[, end]]) Like :meth:`~str.find`, but raise :exc:`ValueError` when the substring is - not found. - - For example:: + not found. For example:: >>> 'spam, spam, spam'.index('eggs') Traceback (most recent call last): @@ -1864,9 +1858,7 @@ expression support in the :mod:`re` module). Return ``True`` if all characters in the string are alphanumeric and there is at least one character, ``False`` otherwise. A character ``c`` is alphanumeric if one of the following returns ``True``: ``c.isalpha()``, ``c.isdecimal()``, - ``c.isdigit()``, or ``c.isnumeric()``. - - For example:: + ``c.isdigit()``, or ``c.isnumeric()``. For example:: >>> ''.isalnum() False @@ -1886,9 +1878,7 @@ expression support in the :mod:`re` module). property being one of "Lm", "Lt", "Lu", "Ll", or "Lo". Note that this is different from the `Alphabetic property defined in the section 4.10 'Letters, Alphabetic, and Ideographic' of the Unicode Standard - `_. - - For example:: + `_. For example:: >>> 'a commom word'.isalpha() False @@ -1908,9 +1898,7 @@ expression support in the :mod:`re` module). Return ``True`` if the string is empty or all characters in the string are ASCII, ``False`` otherwise. - ASCII characters have code points in the range U+0000-U+007F. - - For example:: + ASCII characters have code points in the range U+0000-U+007F. For example:: >>> 'a commom word'.isascii() True @@ -1933,9 +1921,7 @@ expression support in the :mod:`re` module). otherwise. Decimal characters are those that can be used to form numbers in base 10, e.g. U+0660, ARABIC-INDIC DIGIT ZERO. Formally a decimal character is a character in the Unicode - General Category "Nd". - - For example:: + General Category "Nd". For example:: >>> '0123456789'.isdecimal() True @@ -1954,9 +1940,7 @@ expression support in the :mod:`re` module). special handling, such as the compatibility superscript digits. This covers digits which cannot be used to form numbers in base 10, like the Kharosthi numbers. Formally, a digit is a character that has the - property value Numeric_Type=Digit or Numeric_Type=Decimal. - - For example:: + property value Numeric_Type=Digit or Numeric_Type=Decimal. For example:: >>> '0123456789'.isdigit() True @@ -1974,10 +1958,7 @@ expression support in the :mod:`re` module). definition, section :ref:`identifiers`. :func:`keyword.iskeyword` can be used to test whether string ``s`` is a reserved - identifier, such as :keyword:`def` and :keyword:`class`. - - Example: - :: + identifier, such as :keyword:`def` and :keyword:`class`. For example:: >>> from keyword import iskeyword @@ -1990,9 +1971,7 @@ expression support in the :mod:`re` module). .. method:: str.islower() Return ``True`` if all cased characters [4]_ in the string are lowercase and - there is at least one cased character, ``False`` otherwise. - - For example:: + there is at least one cased character, ``False`` otherwise. For example:: >>> 'BANANA'.islower() False @@ -2015,9 +1994,7 @@ expression support in the :mod:`re` module). otherwise. Numeric characters include digit characters, and all characters that have the Unicode numeric value property, e.g. U+2155, VULGAR FRACTION ONE FIFTH. Formally, numeric characters are those with the property - value Numeric_Type=Digit, Numeric_Type=Decimal or Numeric_Type=Numeric. - - For example:: + value Numeric_Type=Digit, Numeric_Type=Decimal or Numeric_Type=Numeric. For example:: >>> '0123456789'.isnumeric() True @@ -2040,9 +2017,7 @@ expression support in the :mod:`re` module). ASCII space (0x20) which is considered printable. (Note that printable characters in this context are those which should not be escaped when :func:`repr` is invoked on a string. It has no bearing on the handling of - strings written to :data:`sys.stdout` or :data:`sys.stderr`.) - - For example:: + strings written to :data:`sys.stdout` or :data:`sys.stderr`.) For example:: >>> ''.isprintable() True @@ -2064,9 +2039,7 @@ expression support in the :mod:`re` module). A character is *whitespace* if in the Unicode character database (see :mod:`unicodedata`), either its general category is ``Zs`` ("Separator, space"), or its bidirectional class is one of ``WS``, - ``B``, or ``S``. - - For example:: + ``B``, or ``S``. For example:: >>> ''.isspace() False @@ -2084,9 +2057,8 @@ expression support in the :mod:`re` module). Return ``True`` if the string is a titlecased string and there is at least one character, for example uppercase characters may only follow uncased characters - and lowercase characters only cased ones. Return ``False`` otherwise. - - For example:: + and lowercase characters only cased ones. Return ``False`` otherwise. For + example:: >>> 'Spam, Spam, Spam'.istitle() True @@ -2101,7 +2073,7 @@ expression support in the :mod:`re` module). .. method:: str.isupper() Return ``True`` if all cased characters [4]_ in the string are uppercase and - there is at least one cased character, ``False`` otherwise. + there is at least one cased character, ``False`` otherwise. For example:: >>> 'BANANA'.isupper() True @@ -2124,9 +2096,7 @@ expression support in the :mod:`re` module). Return a string which is the concatenation of the strings in *iterable*. A :exc:`TypeError` will be raised if there are any non-string values in *iterable*, including :class:`bytes` objects. The separator between - elements is the string providing this method. - - For example:: + elements is the string providing this method. For example:: >>> ', '.join(['spam', 'spam', 'spam']) 'spam, spam, spam' @@ -2139,7 +2109,6 @@ expression support in the :mod:`re` module). Return the string left justified in a string of length *width*. Padding is done using the specified *fillchar* (default is an ASCII space). The original string is returned if *width* is less than or equal to ``len(s)``. - For example:: >>> 'Python'.ljust(10) @@ -2168,7 +2137,8 @@ expression support in the :mod:`re` module). Return a copy of the string with leading characters removed. The *chars* argument is a string specifying the set of characters to be removed. If omitted or ``None``, the *chars* argument defaults to removing whitespace. The *chars* - argument is not a prefix; rather, all combinations of its values are stripped:: + argument is not a prefix; rather, all combinations of its values are stripped. + For example:: >>> ' spacious '.lstrip() 'spacious ' @@ -2193,9 +2163,7 @@ expression support in the :mod:`re` module). If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters (strings of length 1) to Unicode ordinals, strings (of arbitrary lengths) or ``None``. Character keys will then be - converted to ordinals. - - For example:: + converted to ordinals. For example:: >>> str.maketrans({'a': 'A', 'b': 'Boo', 'c': None}) {97: 'A', 98: 'Boo', 99: None} @@ -2203,9 +2171,8 @@ expression support in the :mod:`re` module). If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in *x* will be mapped to the character at the same position in *y*. If there is a third argument, it must be a - string, whose characters will be mapped to ``None`` in the result. - - For example:: + string, whose characters will be mapped to ``None`` in the result. For + example:: >>> str.maketrans('ab', 'AB', 'c') {97: 65, 98: 66, 99: None} @@ -2216,9 +2183,7 @@ expression support in the :mod:`re` module). Split the string at the first occurrence of *sep*, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator. If the separator is not found, return a 3-tuple containing - the string itself, followed by two empty strings. - - For example:: + the string itself, followed by two empty strings. For example:: >>> 'Monty Python'.partition(' ') ('Monty', ' ', 'Python') @@ -2232,7 +2197,7 @@ expression support in the :mod:`re` module). If the string starts with the *prefix* string, return ``string[len(prefix):]``. Otherwise, return a copy of the original - string:: + string. For example:: >>> 'TestHook'.removeprefix('Test') 'Hook' @@ -2246,7 +2211,7 @@ expression support in the :mod:`re` module). If the string ends with the *suffix* string and that *suffix* is not empty, return ``string[:-len(suffix)]``. Otherwise, return a copy of the - original string:: + original string. For example:: >>> 'MiscTests'.removesuffix('Tests') 'Misc' @@ -2260,9 +2225,7 @@ expression support in the :mod:`re` module). Return a copy of the string with all occurrences of substring *old* replaced by *new*. If the optional argument *count* is given, only the first *count* - occurrences are replaced. - - For example:: + occurrences are replaced. For example:: >>> 'spam, spam, spam'.replace('spam', 'eggs') 'eggs, eggs, eggs' @@ -2275,7 +2238,6 @@ expression support in the :mod:`re` module). Return the highest index in the string where substring *sub* is found, such that *sub* is contained within ``s[start:end]``. Optional arguments *start* and *end* are interpreted as in slice notation. Return ``-1`` on failure. - For example:: >>> 'spam, spam, spam'.rfind('sp') @@ -2289,9 +2251,7 @@ expression support in the :mod:`re` module). .. method:: str.rindex(sub[, start[, end]]) Like :meth:`rfind` but raises :exc:`ValueError` when the substring *sub* is not - found. - - For example:: + found. For example:: >>> 'spam, spam, spam'.rindex('eggs') Traceback (most recent call last): @@ -2306,7 +2266,6 @@ expression support in the :mod:`re` module). Return the string right justified in a string of length *width*. Padding is done using the specified *fillchar* (default is an ASCII space). The original string is returned if *width* is less than or equal to ``len(s)``. - For example:: >>> 'Python'.rjust(10) @@ -2322,9 +2281,7 @@ expression support in the :mod:`re` module). Split the string at the last occurrence of *sep*, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator. If the separator is not found, return a 3-tuple containing - two empty strings, followed by the string itself. - - For example:: + two empty strings, followed by the string itself. For example:: >>> "Monty Python's Flying Circus".rpartition(' ') ("Monty Python's Flying", ' ', 'Circus') @@ -2338,9 +2295,7 @@ expression support in the :mod:`re` module). If *maxsplit* is given, at most *maxsplit* splits are done, the *rightmost* ones. If *sep* is not specified or ``None``, any whitespace string is a separator. Except for splitting from the right, :meth:`rsplit` behaves like - :meth:`split` which is described in detail below. - - For example:: + :meth:`split` which is described in detail below. For example:: >>> '1,2,3'.rsplit(',', maxsplit=1) ['1,2', '3'] @@ -2351,7 +2306,8 @@ expression support in the :mod:`re` module). Return a copy of the string with trailing characters removed. The *chars* argument is a string specifying the set of characters to be removed. If omitted or ``None``, the *chars* argument defaults to removing whitespace. The *chars* - argument is not a suffix; rather, all combinations of its values are stripped:: + argument is not a suffix; rather, all combinations of its values are stripped. + For example:: >>> ' spacious '.rstrip() ' spacious' @@ -2359,7 +2315,7 @@ expression support in the :mod:`re` module). 'mississ' See :meth:`str.removesuffix` for a method that will remove a single suffix - string rather than all of a set of characters. For example:: + string rather than all of a set of characters. For example:: >>> 'Monty Python'.rstrip(' Python') 'M' @@ -2382,7 +2338,6 @@ expression support in the :mod:`re` module). ``['1', '', '2']``). The *sep* argument may consist of multiple characters (for example, ``'1<>2<>3'.split('<>')`` returns ``['1', '2', '3']``). Splitting an empty string with a specified separator returns ``['']``. - For example:: >>> '1,2,3'.split(',') @@ -2397,9 +2352,7 @@ expression support in the :mod:`re` module). and the result will contain no empty strings at the start or end if the string has leading or trailing whitespace. Consequently, splitting an empty string or a string consisting of just whitespace with a ``None`` separator - returns ``[]``. - - For example:: + returns ``[]``. For example:: >>> '1 2 3'.split() ['1', '2', '3'] @@ -2482,9 +2435,7 @@ expression support in the :mod:`re` module). Return ``True`` if string starts with the *prefix*, otherwise return ``False``. *prefix* can also be a tuple of prefixes to look for. With optional *start*, test string beginning at that position. With optional *end*, stop comparing - string at that position. - - For example: + string at that position. For example:: >>> 'Python'.startswith('Py') True @@ -2504,7 +2455,7 @@ expression support in the :mod:`re` module). The *chars* argument is a string specifying the set of characters to be removed. If omitted or ``None``, the *chars* argument defaults to removing whitespace. The *chars* argument is not a prefix or suffix; rather, all combinations of its - values are stripped:: + values are stripped. For example:: >>> ' spacious '.strip() 'spacious' @@ -2526,9 +2477,7 @@ expression support in the :mod:`re` module). Return a copy of the string with uppercase characters converted to lowercase and vice versa. Note that it is not necessarily true that - ``s.swapcase().swapcase() == s``. - - For example:: + ``s.swapcase().swapcase() == s``. For example:: >>> 'Monty Python'.swapcase() 'mONTY pYTHON' @@ -2539,9 +2488,7 @@ expression support in the :mod:`re` module). .. method:: str.title() Return a titlecased version of the string where words start with an uppercase - character and the remaining characters are lowercase. - - For example:: + character and the remaining characters are lowercase. For example:: >>> 'Hello world'.title() 'Hello World' @@ -2549,7 +2496,7 @@ expression support in the :mod:`re` module). The algorithm uses a simple language-independent definition of a word as groups of consecutive letters. The definition works in many contexts but it means that apostrophes in contractions and possessives form word - boundaries, which may not be the desired result:: + boundaries, which may not be the desired result. For example:: >>> "they're bill's friends from the UK".title() "They'Re Bill'S Friends From The Uk" @@ -2558,7 +2505,7 @@ expression support in the :mod:`re` module). splits words on spaces only. Alternatively, a workaround for apostrophes can be constructed using regular - expressions:: + expressions. For example:: >>> import re >>> def titlecase(s): @@ -2584,9 +2531,7 @@ expression support in the :mod:`re` module). :exc:`LookupError` exception, to map the character to itself. You can use :meth:`str.maketrans` to create a translation map from - character-to-character mappings in different formats. - - For example:: + character-to-character mappings in different formats. For example:: >>> str.maketrans('to', '70') {116: 55, 111: 48} @@ -2603,9 +2548,7 @@ expression support in the :mod:`re` module). uppercase. Note that ``s.upper().isupper()`` might be ``False`` if ``s`` contains uncased characters or if the Unicode category of the resulting character(s) is not "Lu" (Letter, uppercase), but e.g. "Lt" (Letter, - titlecase). - - For example:: + titlecase). For example:: >>> 'Monty Python'.upper() 'MONTY PYTHON' @@ -2625,9 +2568,7 @@ expression support in the :mod:`re` module). make a string of length *width*. A leading sign prefix (``'+'``/``'-'``) is handled by inserting the padding *after* the sign character rather than before. The original string is returned if *width* is less than - or equal to ``len(s)``. - - For example:: + or equal to ``len(s)``. For example:: >>> "42".zfill(5) '00042' From e4e140546da470c12a79ab4ce492db67c8a3f9d9 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Mon, 3 Jul 2023 11:41:54 +0100 Subject: [PATCH 41/43] [DOC] Putting a space after # in comments on str methods --- Doc/library/stdtypes.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 4d7c642e883c62..f4e2ecdf203a3a 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1944,7 +1944,7 @@ expression support in the :mod:`re` module). >>> '0123456789'.isdigit() True - >>> '٠١٢٣٤٥٦٧٨٩'.isdigit() #ARABIC-INDIC DIGIT ZERO TO NINE + >>> '٠١٢٣٤٥٦٧٨٩'.isdigit() # ARABIC-INDIC DIGIT ZERO TO NINE True >>> '²'.isdigit(), '²'.isdecimal() (True, False) @@ -1998,7 +1998,7 @@ expression support in the :mod:`re` module). >>> '0123456789'.isnumeric() True - >>> '٠١٢٣٤٥٦٧٨٩'.isnumeric() #ARABIC-INDIC DIGIT ZERO TO NINE + >>> '٠١٢٣٤٥٦٧٨٩'.isnumeric() # ARABIC-INDIC DIGIT ZERO TO NINE True >>> '⅕'.isnumeric() # VULGAR FRACTION ONE FIFTH True From 2dfa3f2a78535995ad763bfa36484a5228197ae6 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Mon, 3 Jul 2023 11:54:16 +0100 Subject: [PATCH 42/43] [DOC] Fixed inconsistent literal block quoting --- Doc/library/stdtypes.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index f4e2ecdf203a3a..389ed9b7436428 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1830,12 +1830,12 @@ expression support in the :mod:`re` module). used directly and not copied to a :class:`dict`. This is useful if for example ``mapping`` is a dict subclass. For example:: - >>> class Default(dict): - ... def __missing__(self, key): - ... return key - ... - >>> '{name} was born in {country}'.format_map(Default(name='Guido')) - 'Guido was born in country' + >>> class Default(dict): + ... def __missing__(self, key): + ... return key + ... + >>> '{name} was born in {country}'.format_map(Default(name='Guido')) + 'Guido was born in country' .. versionadded:: 3.2 From 27cc3278016a1047ddcc17ef23eaf1583c96c696 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Mon, 3 Jul 2023 12:40:49 -0700 Subject: [PATCH 43/43] fix other comments --- Doc/library/stdtypes.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 389ed9b7436428..9adb9f7525f87a 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1944,7 +1944,7 @@ expression support in the :mod:`re` module). >>> '0123456789'.isdigit() True - >>> '٠١٢٣٤٥٦٧٨٩'.isdigit() # ARABIC-INDIC DIGIT ZERO TO NINE + >>> '٠١٢٣٤٥٦٧٨٩'.isdigit() # ARABIC-INDIC DIGIT ZERO TO NINE True >>> '²'.isdigit(), '²'.isdecimal() (True, False) @@ -1998,9 +1998,9 @@ expression support in the :mod:`re` module). >>> '0123456789'.isnumeric() True - >>> '٠١٢٣٤٥٦٧٨٩'.isnumeric() # ARABIC-INDIC DIGIT ZERO TO NINE + >>> '٠١٢٣٤٥٦٧٨٩'.isnumeric() # ARABIC-INDIC DIGIT ZERO TO NINE True - >>> '⅕'.isnumeric() # VULGAR FRACTION ONE FIFTH + >>> '⅕'.isnumeric() # VULGAR FRACTION ONE FIFTH True >>> '²'.isdigit(), '²'.isdecimal(), '²'.isnumeric() (True, False, True) @@ -2023,9 +2023,9 @@ expression support in the :mod:`re` module). True >>> ' '.isprintable() True - >>> '\t\n'.isprintable() # TAB and BREAK LINE + >>> '\t\n'.isprintable() # TAB and BREAK LINE False - >>> '\u3000'.isprintable() # IDEOGRAPHIC SPACE + >>> '\u3000'.isprintable() # IDEOGRAPHIC SPACE False See also :meth:`isspace`. @@ -2045,9 +2045,9 @@ expression support in the :mod:`re` module). False >>> ' '.isspace() True - >>> '\t\n'.isspace() # TAB and BREAK LINE + >>> '\t\n'.isspace() # TAB and BREAK LINE True - >>> '\u3000'.isspace() # IDEOGRAPHIC SPACE + >>> '\u3000'.isspace() # IDEOGRAPHIC SPACE True See also :meth:`isprintable`. @@ -2552,7 +2552,7 @@ expression support in the :mod:`re` module). >>> 'Monty Python'.upper() 'MONTY PYTHON' - >>> '𐊠'.upper().isupper() # 'CARIAN LETTER A' + >>> '𐊠'.upper().isupper() # 'CARIAN LETTER A' False The uppercasing algorithm used is