[Python-ideas] float('∞')=float('inf')

Joshua Landau joshua at landau.ws
Fri Jul 12 16:02:06 CEST 2013


On 12 July 2013 14:43, Laurens Van Houtven <_ at lvh.io> wrote:
> On Fri, Jul 12, 2013 at 3:21 PM, Gerald Britton <gerald.britton at gmail.com>
> wrote:
>>
>> >> Do you have the infinity symbol on your keyboard?  I don't!.
>> >>
>>
>> >Why does what you have on your keyboard matter? Just because the example
>> >uses a string literal, doesn't mean that's the only use case. I can pass
>> >infinity symbols along in any text medium.
>>
>> Ummm...cause that's what I use when programming?
>
>
> My point is that this doesn't have to come from source code. It can come
> from any kind of user input, which is the more common use case for calling
> float or int in the first place. If you just wanted the number, you'd just
> type the literal. (Infinity, of course, is a little special, since it
> doesn't have a literal -- just float("inf")).

I'd try phrasing it as the same sort of thing as what caused the
internationalisation aspect to what float and int can receive -- they
now accept foreign numbers:

>>> float("߂߃߄")
234.0

Consider also that float accepts "infinity" as well as "inf", and any
variant of capitalization. I think it's reasonable that unicode
infinity is allowed.

However, we don't take all forms of negative symbols or decimal
points, so it's not like anything goes.


More information about the Python-ideas mailing list