Difference between str.isdigit() and str.isdecimal() in Python 3
Ulrich Eckhardt
doomster at knuut.de
Wed May 16 12:24:57 EDT 2012
Marco wrote:
> >>> '123'.isdecimal(), '123'.isdigit()
> (True, True)
> >>> print('\u0660123')
> ٠123
> >>> '\u0660123'.isdigit(), '\u0660123'.isdecimal()
> (True, True)
> >>> print('\u216B')
> Ⅻ
> >>> '\u216B'.isdecimal(), '\u216B'.isdigit()
> (False, False)
[chr(a) for a in range(0x20000) if chr(a).isdigit()]
Congratulations, you found a bug! Or maybe not, it all depends on whether
Roman numbers are considered digits or not. I could imagine there being a
difference.
:)
Uli
More information about the Python-list
mailing list