[Python-ideas] float('∞')=float('inf')
Joshua Landau
joshua at landau.ws
Fri Jul 12 18:15:22 CEST 2013
On 12 July 2013 17:09, Alexander Belopolsky
<alexander.belopolsky at gmail.com> wrote:
>
> On Fri, Jul 12, 2013 at 11:45 AM, Joshua Landau <joshua at landau.ws> wrote:
>>
>> No. Why would we special-case ½? We'd need a ton of code just to
>> special-case ½, ¾, ⅛, ¼, ⅜, ⅝, ⅞, etc. We don't need or want to
>> special-case any more values.
>
> You don't need to special-case every fraction:
>
>>>> import unicodedata
>>>> [unicodedata.numeric(c) for c in ['½', '¾', '⅛', '¼', '⅜', '⅝', '⅞']]
> [0.5, 0.75, 0.125, 0.25, 0.375, 0.625, 0.875]
That's a good point.
> I would actually support the idea for float() to accept whatever
> unicodedata.numeric() accepts.
It doesn't free us from tons of special cases. We already have people
arguing over whether 3½ is the traditional 3.5 or whether it's 1.5.
We'll need tons of new parsing rules. I'm not convinced, in other
words.
Additionally, core devs have rejected multiple "negative signs"
despite the fact that there is an alternate standard "negative sign".
A change of this size is a bit further than reasonable. If it were as
simple as just calling "unicodedata.numeric" rather than rewriting the
whole float and int parser, I'd not be so hesitant.
More information about the Python-ideas
mailing list