str.isnumeric()

The widest numeric check — a superset of isdigit that accepts any character Unicode considers numeric.

String methodPython 1.0+Live demo
Common call
if s.isnumeric():
Returns
True or False
Replaces
isdigit when you also want Roman numerals, fractions, or superscripts
Watch out
does NOT mean "can be converted with int() or float()"; decimals ("3.14") return False
str.isnumeric()
bool

Demo

Live evaluation
Try:
Inputs
stringstrthe string to test
Output
'12345'.isnumeric()
True

isnumeric() is the WIDEST of the numeric check family. It returns True for anything Unicode classifies as having a numeric value — digits, fractions like ½ and ¾, Roman numerals like Ⅳ and Ⅻ, superscript numbers like ² and ³, and Arabic-Indic or Devanagari digits. It does NOT accept decimal points, minus signs, or spaces. "3.14" returns False (the dot is not numeric); "-42" returns False (the minus is not numeric).

Common patterns

Detect any Unicode number-shaped input
Widest net when you want to accept every notation.
if token.isnumeric():
    ...    # digits, fractions, Roman, superscripts
Widest reject-on-non-number
Combine with isalpha for a "something meaningful" check.
if not (s.isnumeric() or s.isalpha()):
    reject(s)
Explicit ASCII-only check
Restrict to ASCII digits by combining with .isascii().
if s.isascii() and s.isdigit():
    ...    # ASCII 0-9 only

Examples

1. Plain digits
"12345".isnumeric()
Returns
True
2. Fraction
"½".isnumeric()
Returns
True
3. Roman numeral
"Ⅳ".isnumeric()
Returns
True
4. Superscript
"²".isnumeric()
Returns
True
5. Arabic-Indic
"٥٦٧".isnumeric()
Returns
True
6. Decimal fails
"3.14".isnumeric()
Returns
False # the dot
7. Negative fails
"-42".isnumeric()
Returns
False # the minus
8. Empty is False
"".isnumeric()
Returns
False

Pitfalls

1. isnumeric does NOT mean "can be converted to a number"
The most common misconception. isnumeric accepts fractions and Roman numerals but rejects decimals and signs. int("3.14") raises; float("½") also raises. isnumeric is about Unicode categorization, not parseability.
Decimal misleadingly rejected
"3.14".isnumeric()
False # not "3" plus digit — the dot fails
Try/except to test parseability
def is_parseable_number(s):
    try:
        float(s)
        return True
    except ValueError:
        return False
True on "3.14"
2. isdigit vs isnumeric vs isdecimal — three widths
isdecimal is narrowest (only decimal digits like 0-9). isdigit adds superscripts and a few more. isnumeric is widest — fractions, Roman numerals, and every Unicode numeric character.
Wrong tool
"½".isdigit()
False
Right width
"½".isnumeric()
True
3. Empty string returns False
Same rule as the rest of the is* family — empty is False by convention.
Wrong expectation
"".isnumeric()
False
Guard first
s and s.isnumeric()
covers the empty case
4. Signs and separators are NOT numeric characters
The minus sign, plus sign, decimal point, thousands separator, and currency symbols all count as punctuation or symbols — not numeric. Even "-42", which looks numeric to a human, returns False.
Sign rejected
"-42".isnumeric()
False
Strip sign first
s.lstrip("-+").isnumeric()
True on "-42"

When to use

Use it
  • Accepting a wide range of Unicode number-shaped strings
  • Filtering tokens that consist entirely of numeric characters
  • Detecting non-ASCII numbers (Arabic-Indic, Devanagari, Roman)
  • Combining with isalpha for "is this a meaningful token?" checks
Reach for something else
  • You want to know if it PARSES to a number → try int()/float() with try/except
  • You want ASCII digits only → isdecimal or isascii+isdigit
  • Signs / decimals / thousands separators need to pass → parse instead of classify
  • Rich validation (bounds, format) → use a regex or validator library

Notes

Complexity
O(n) — one linear scan
Return
bool — True or False
CPython impl
Objects/unicodeobject.c :: unicode_isnumeric
Memory
No allocation
Thread-safe
Yes — strings are immutable

FAQ

Three widths of "numeric character". isdecimal is narrowest — only characters that could be part of a base-10 integer literal. isdigit adds superscripts and a few decimal-like forms. isnumeric is widest — fractions, Roman numerals, and every Unicode-classified numeric character.

History

1.0
isnumeric() has been part of str since Python 1.0.
3.0
Full Unicode support — the widest numeric-character classifier in the is* family.