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

M.-A. Lemburg mal at egenix.com
Sun Jun 9 13:13:01 CEST 2013


On 09.06.2013 08:21, Terry Jan Reedy wrote:
> On 6/9/2013 1:30 AM, Guido van Rossum wrote:
>> I'm beginning to feel that it was even a mistake to accept all those
>> other Unicode decimal digits, because it leads to the mistaken belief
>> that one can parse a number without knowing the locale. Python's
>> position about this is very different from what the heuristics you
>> quote seem to suggest: "refuse the temptation to guess" leads to our
>> current, simple rule which only accepts '.' as the decimal indicator,
>> and leaves localized parsing strictly to the application (or to some
>> other library module).
> 
> The referenced algorithm is about extracting number literals, especially integel, out of text. Doing
> that 'properly' depends on local and purpose. Int is about converting a literal to its numberic
> value, whether written directly or extracted. Once a decision is made to convert a literal,
> conversion itself (for integers) is not location dependent.
> 
>> Still, I suppose I could defend the current behavior from the
>> perspective of writing such a localized parser -- at some point you've
>> got a digit and you need to know its numeric value, and it is
>> convenient that int(c) does so.
> 
> Exactly. I believe that is why it was extended to do that.

I added this support as part of the Unicode integration in Python 1.6
in order to support the full range of Unicode digits - just like
we support more characters and mappings for e.g. line breaks,
lower/upper case, etc. in Unicode than in 8-bit character sets.

Note that the decimal encoder does not support right-to-left scripts.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Jun 09 2013)
>>> Python Projects, Consulting and Support ...   http://www.egenix.com/
>>> mxODBC.Zope/Plone.Database.Adapter ...       http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________
2013-07-01: EuroPython 2013, Florence, Italy ...           22 days to go
2013-07-16: Python Meeting Duesseldorf ...                 37 days to go

::::: Try our mxODBC.Connect Python Database Interface for free ! ::::::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/


More information about the Python-ideas mailing list