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

Karthikeyan Singaravelan report at bugs.python.org
Sun Feb 24 05:31:50 EST 2019


Karthikeyan Singaravelan <tir.karthi at gmail.com> added the comment:

Not a unicode expert but searching along the lines there was a note added on issue10610 that int() is supported for characters of 'Nd' category. So to check if a string can be converted to integer with help of int() I should be using str.isdecimal() instead of str.isnumeric() ?

https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex

> The numeric literals accepted include the digits 0 to 9 or any Unicode equivalent (code points with the Nd property). See http://www.unicode.org/Public/10.0.0/ucd/extracted/DerivedNumericType.txt for a complete list of code points with the Nd property.


>>> [unicodedata.category(c) for c in '一二三四五']
['Lo', 'Lo', 'Lo', 'Lo', 'Lo']
>>> [unicodedata.category(c) for c in '\N{BENGALI DIGIT ONE}\N{BENGALI DIGIT TWO}']
['Nd', 'Nd']

----------
nosy: +xtreak

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


More information about the Python-bugs-list mailing list