[Python-Dev] Python and the Unicode Character Database

M.-A. Lemburg mal at egenix.com
Sun Nov 28 23:42:31 CET 2010



"Martin v. Löwis" wrote:
>>>>>> float('١٢٣٤.٥٦')
>>> 1234.56
> 
> I think it's a bug that this works. The definition of the float builtin says
> 
> Convert a string or a number to floating point. If the argument is a
> string, it must contain a possibly signed decimal or floating point
> number, possibly embedded in whitespace. The argument may also be
> '[+|-]nan' or '[+|-]inf'.
> 
> Now, one may wonder what precisely a "possibly signed floating point
> number" is, but most likely, this refers to
> 
> floatnumber   ::=  pointfloat | exponentfloat
> pointfloat    ::=  [intpart] fraction | intpart "."
> exponentfloat ::=  (intpart | pointfloat) exponent
> intpart       ::=  digit+
> fraction      ::=  "." digit+
> exponent      ::=  ("e" | "E") ["+" | "-"] digit+
> digit          ::=  "0"..."9"

I don't see why the language spec should limit the wealth of number
formats supported by float().

It is not uncommon for Asians and other non-Latin script users to
use their own native script symbols for numbers. Just because these
digits may look strange to someone doesn't mean that they are
meaningless or should be discarded.

Please also remember that Python3 now allows Unicode names for
identifiers for much the same reasons.

Note that the support in float() (and the other numeric constructors)
to work with Unicode code points was explicitly added when Unicode
support was added to Python and has been available since Python 1.6.

It is not a bug by any definition of "bug", even though the feature
may bug someone occasionally to go read up a bit on what else
the world has to offer other than Arabic numerals :-)

    http://en.wikipedia.org/wiki/Numeral_system

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Nov 28 2010)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try our new 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-Dev mailing list