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

2019-02-24 Thread Marcos Dione
Marcos Dione added the comment: Thanks for all the examples, I'm convinced. -- resolution: -> not a bug stage: -> resolved status: open -> closed versions: +Python 3.4, Python 3.5, Python 3.6 ___ Python tracker

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

2019-02-24 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Agreed, though str.isnumeric behavior might seem to be correct in terms of user who knows unicode internals the naming makes it easy to be used for a general user on trying to determine if the string can be used for int() without knowing unicode

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

2019-02-24 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Sun, Feb 24, 2019 at 11:07:41AM +, Karthikeyan Singaravelan wrote: > 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

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

2019-02-24 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan 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 >>>

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

2019-02-24 Thread Mark Dickinson
Mark Dickinson added the comment: > which corresponds to `str.isdigit`. Gah! That should have said: > which corresponds to `str.isdecimal`. Sorry. -- ___ Python tracker

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

2019-02-24 Thread Mark Dickinson
Mark Dickinson added the comment: > 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() ? Yes, I think that's correct. The characters matched by `str.isdecimal` are a subset of those matched by `str.isdigit`,

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

2019-02-24 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan 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

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

2019-02-24 Thread Mark Dickinson
Mark Dickinson added the comment: > What value would you expect `int(s)` to have in this situation? Actually, I guess that question was too easy. The value for `int(s)` should *obviously* be 23 * 1000 + (3/5) * 100 + 17 * 10 + 12 = 23242. I should have used ⅐ instead of ⅗. Anyway, agreed

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

2019-02-24 Thread Mark Dickinson
Mark Dickinson 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 = "㉓⅗⒘Ⅻ"

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

2019-02-24 Thread Steven D'Aprano
Steven D'Aprano added the comment: I think that analysis is wrong. The Wikipedia page describes the meaning of the Unicode Decimal/Digit/Numeric properties: https://en.wikipedia.org/wiki/Unicode_character_property#Numeric_values_and_types and the characters you show aren't appropriate for

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

2019-02-24 Thread Marcos Dione
New submission from Marcos Dione : Following https://blog.lerner.co.il/pythons-str-isdigit-vs-str-isnumeric/, we have this: Python 3.8.0a1+ (heads/master:001fee14e0, Feb 20 2019, 08:28:02) [GCC 8.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>>