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

Karthikeyan Singaravelan report at bugs.python.org
Sun Feb 24 06:07:41 EST 2019


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

> `int` and `float` required general category Nd, which corresponds to `str.isdigit`.

Sorry, did you mean str.isdecimal? since there could be a subset where isdigit is True and isdecimal returns False. 

>>> '\u00B2'.isdecimal()
False
>>> '\u00B2'.isdigit()
True
>>> import unicodedata
>>> unicodedata.category('\u00B2')
'No'
>>> int('\u00B2')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '²'

Is this worth an FAQ or an addition to the existing note on int that specifies characters should belong to 'Nd' category to add a note that str.isdecimal should return True

----------

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


More information about the Python-bugs-list mailing list