[Python-ideas] [Python-Dev] Unicode minus sign in numeric conversions

Stephen J. Turnbull stephen at xemacs.org
Tue Jun 11 05:56:00 CEST 2013


MRAB writes:

 > In that case, float and int should accept different scripts, but not
 > mixed scripts.

Possibly.  I don't see any compelling use case for builtins accepting
any numerical syntax that can't be used in a Python program.  I doubt
there's any computer[1] user in the world who doesn't understand "-1"
as well as its representation in their local script, or isn't already
used to using ASCII characters for numeric input.

 > > The builtins are in any case poorly suited for input conversion, since
 > > they should not be localized.
 > >
 > I think that it would be best to trial it on PyPI first!

Unfortunately, we already have float and int that violate the UTR #36
recommendation, and eval("\uff11") raises an identifier syntax error,
while int("\uff11") == 1.

For web use, obviously we need to consider cut and paste and other
situations where data is received in presentation format, and it's
quite possible that in the future programs like Matlab and R will
output \N{MINUS SIGN} instead of "-".[2]  If I could do what I wanted
to without worrying about backward compatibility, I'd move the current
builtins to someplace like unicodedata.parsers.numeric.integer_insecure
and so on, and revert the builtins to accepting only the output of
str(int) and str(float).


Footnotes: 
[1]  Defining "computer" broadly to at least include 4 function
calculators and telephones smart enough to text message.

[2]  This is a Unicode recommendation, I'd be willing to bet.



More information about the Python-ideas mailing list