Skip to content

Commit 33535e0

Browse files
committed
gh-106318: Add examples for str.isdigit() method docs
1 parent 3718f4b commit 33535e0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Doc/library/stdtypes.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,6 +2264,22 @@ expression support in the :mod:`re` module).
22642264
like the Kharosthi numbers. Formally, a digit is a character that has the
22652265
property value Numeric_Type=Digit or Numeric_Type=Decimal.
22662266

2267+
For example:
2268+
2269+
.. doctest::
2270+
2271+
>>> '0123456789'.isdigit()
2272+
True
2273+
>>> '٠١٢٣٤٥٦٧٨٩'.isdigit() # Arabic-indic digits zero to nine
2274+
True
2275+
>>> ''.isdigit() # Vulgar fraction one fifth
2276+
False
2277+
>>> '²'.isdecimal(), '²'.isdigit(), '²'.isnumeric()
2278+
(False, True, True)
2279+
2280+
See also :meth:`isdecimal` and :meth:`isnumeric`. Digital characters are a
2281+
superset of decimal characters.
2282+
22672283

22682284
.. method:: str.isidentifier()
22692285

0 commit comments

Comments
 (0)