Skip to content

Commit 4e2285c

Browse files
miss-islingtonadorilsonStanFromIreland
authored
[3.13] 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 45d1ba7 commit 4e2285c

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
@@ -2023,9 +2023,25 @@ expression support in the :mod:`re` module).
20232023
character, ``False`` otherwise. Digits include decimal characters and digits that need
20242024
special handling, such as the compatibility superscript digits.
20252025
This covers digits which cannot be used to form numbers in base 10,
2026-
like the Kharosthi numbers. Formally, a digit is a character that has the
2026+
like the `Kharosthi numbers <https://en.wikipedia.org/wiki/Kharosthi#Numerals>`__.
2027+
Formally, a digit is a character that has the
20272028
property value Numeric_Type=Digit or Numeric_Type=Decimal.
20282029

2030+
For example:
2031+
2032+
.. doctest::
2033+
2034+
>>> '0123456789'.isdigit()
2035+
True
2036+
>>> '٠١٢٣٤٥٦٧٨٩'.isdigit() # Arabic-Indic digits zero to nine
2037+
True
2038+
>>> ''.isdigit() # Vulgar fraction one fifth
2039+
False
2040+
>>> '²'.isdecimal(), '²'.isdigit(), '²'.isnumeric()
2041+
(False, True, True)
2042+
2043+
See also :meth:`isdecimal` and :meth:`isnumeric`.
2044+
20292045

20302046
.. method:: str.isidentifier()
20312047

@@ -2066,15 +2082,14 @@ expression support in the :mod:`re` module).
20662082

20672083
>>> '0123456789'.isnumeric()
20682084
True
2069-
>>> '٠١٢٣٤٥٦٧٨٩'.isnumeric() # Arabic-indic digit zero to nine
2085+
>>> '٠١٢٣٤٥٦٧٨٩'.isnumeric() # Arabic-Indic digits zero to nine
20702086
True
20712087
>>> ''.isnumeric() # Vulgar fraction one fifth
20722088
True
20732089
>>> '²'.isdecimal(), '²'.isdigit(), '²'.isnumeric()
20742090
(False, True, True)
20752091

2076-
See also :meth:`isdecimal` and :meth:`isdigit`. Numeric characters are
2077-
a superset of decimal numbers.
2092+
See also :meth:`isdecimal` and :meth:`isdigit`.
20782093

20792094

20802095
.. method:: str.isprintable()

0 commit comments

Comments
 (0)