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

Gerald Britton gerald.britton at gmail.com
Fri Jul 12 16:43:18 CEST 2013


Man I don't know how you are doing this!  I just tried:

float('<greek letter pi>') and got

Value error: could not convert string to float '<greek letter pi>'

For that matter, I can't figure out how to type the greek letter for
pi in gmail!  Guess I have some things to learn.

So, if Python doesn't recognize the symbol for pi, why should it
recognize the one for infinity?


On Fri, Jul 12, 2013 at 10:02 AM, Joshua Landau <joshua at landau.ws> wrote:
> 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.



-- 
Gerald Britton


More information about the Python-ideas mailing list