]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-106318: Add examples for str.isnumeric() (GH-142680) (#142715)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 14 Dec 2025 18:53:13 +0000 (19:53 +0100)
committerGitHub <noreply@github.com>
Sun, 14 Dec 2025 18:53:13 +0000 (18:53 +0000)
Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Doc/library/stdtypes.rst

index 9bb903688bc0d36aa6d41919433406da4e34dc66..ffab8f854f344b2e2d1b5b0ff67005cc0d1a87eb 100644 (file)
@@ -2155,6 +2155,21 @@ expression support in the :mod:`re` module).
    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:
+
+   .. doctest::
+
+      >>> '0123456789'.isnumeric()
+      True
+      >>> '٠١٢٣٤٥٦٧٨٩'.isnumeric()  # Arabic-indic digit zero to nine
+      True
+      >>> '⅕'.isnumeric()  # Vulgar fraction one fifth
+      True
+      >>> '²'.isdecimal(), '²'.isdigit(),  '²'.isnumeric()
+      (False, True, True)
+
+   See also :meth:`isdecimal` and :meth:`isdigit`. Numeric characters are
+   a superset of decimal numbers.
 
 
 .. method:: str.isprintable()