[issue36100] int() and float() should accept any isnumeric() digit

Mark Dickinson report at bugs.python.org
Sun Feb 24 05:14:50 EST 2019


Mark Dickinson <dickinsm at gmail.com> added the comment:

[Steven posted his answer while I was composing mine; posting mine anyway ...]

I don't think this would make sense. There are lots of characters that can't be interpreted as a decimal digit but for which `isnumeric` nevertheless gives True.

>>> s = "㉓⅗⒘Ⅻ"
>>> for c in s: print(unicodedata.name(c))
... 
CIRCLED NUMBER TWENTY THREE
VULGAR FRACTION THREE FIFTHS
NUMBER SEVENTEEN FULL STOP
ROMAN NUMERAL TWELVE
>>> s.isnumeric()
True

What value would you expect `int(s)` to have in this situation?

Note that `int` and `float` already accept non-ASCII digits:

>>> s = "١٢٣٤٥٦٧٨٩"
>>> int(s)
123456789
>>> float(s)
123456789.0

----------
nosy: +mark.dickinson

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36100>
_______________________________________


More information about the Python-bugs-list mailing list