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

Chris Angelico rosuav at gmail.com
Fri Jul 12 17:51:20 CEST 2013


On Sat, Jul 13, 2013 at 1:42 AM, Serhiy Storchaka <storchaka at gmail.com> wrote:
> 12.07.13 17:52, Chris Angelico написав(ла):
>>
>> On Sat, Jul 13, 2013 at 12:43 AM, Gerald Britton
>> <gerald.britton at gmail.com> wrote:
>>>
>>> So, if Python doesn't recognize the symbol for pi, why should it
>>> recognize the one for infinity?
>>
>>
>> Considering that Python can't represent π in a float anyway, I
>> wouldn't be too bothered.
>
>
> However Python can represent ½ in a float. Shouldn't it recognize the symbol
> for ½?

That one would be more plausible, in the same way that many of the
other Unicode digits are accepted. Not sure there's all that much of a
use-case for it, though, and if it's going to complicate the code I
wouldn't bother; for instance, it's fairly obvious that "3½" should be
accepted, but what does "½3" mean? I'm -0 on it initially, but would
change that to +0 if a suitable answer is found for that (even if it's
"raise ValueError, same as float('1.1.1') does") that doesn't make the
code horrendous.

ChrisA


More information about the Python-ideas mailing list