Skip to content

Commit 86e291e

Browse files
miss-islingtonadorilsonStanFromIreland
authored
[3.15] gh-106318: Add examples to the str.isdigit() method docs (GH-144721)
(cherry picked from commit f051c68) Co-authored-by: Adorilson Bezerra <adorilson@gmail.com> Co-authored-by: Stan Ulbrych <stan@python.org>
1 parent 39f2322 commit 86e291e

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

Doc/library/stdtypes.rst

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2174,9 +2174,25 @@ expression support in the :mod:`re` module).
21742174
character, ``False`` otherwise. Digits include decimal characters and digits that need
21752175
special handling, such as the compatibility superscript digits.
21762176
This covers digits which cannot be used to form numbers in base 10,
2177-
like the Kharosthi numbers. Formally, a digit is a character that has the
2177+
like the `Kharosthi numbers <https://en.wikipedia.org/wiki/Kharosthi#Numerals>`__.
2178+
Formally, a digit is a character that has the
21782179
property value Numeric_Type=Digit or Numeric_Type=Decimal.
21792180

2181+
For example:
2182+
2183+
.. doctest::
2184+
2185+
>>> '0123456789'.isdigit()
2186+
True
2187+
>>> '٠١٢٣٤٥٦٧٨٩'.isdigit() # Arabic-Indic digits zero to nine
2188+
True
2189+
>>> ''.isdigit() # Vulgar fraction one fifth
2190+
False
2191+
>>> '²'.isdecimal(), '²'.isdigit(), '²'.isnumeric()
2192+
(False, True, True)
2193+
2194+
See also :meth:`isdecimal` and :meth:`isnumeric`.
2195+
21802196

21812197
.. method:: str.isidentifier()
21822198

@@ -2217,15 +2233,14 @@ expression support in the :mod:`re` module).
22172233

22182234
>>> '0123456789'.isnumeric()
22192235
True
2220-
>>> '٠١٢٣٤٥٦٧٨٩'.isnumeric() # Arabic-indic digit zero to nine
2236+
>>> '٠١٢٣٤٥٦٧٨٩'.isnumeric() # Arabic-Indic digits zero to nine
22212237
True
22222238
>>> ''.isnumeric() # Vulgar fraction one fifth
22232239
True
22242240
>>> '²'.isdecimal(), '²'.isdigit(), '²'.isnumeric()
22252241
(False, True, True)
22262242

2227-
See also :meth:`isdecimal` and :meth:`isdigit`. Numeric characters are
2228-
a superset of decimal numbers.
2243+
See also :meth:`isdecimal` and :meth:`isdigit`.
22292244

22302245

22312246
.. method:: str.isprintable()

0 commit comments

Comments
 (0)