[Python-ideas] float('∞')=float('inf')
Joshua Landau
joshua at landau.ws
Sat Jul 13 02:12:48 CEST 2013
On 12 July 2013 23:20, Alexander Belopolsky
<alexander.belopolsky at gmail.com>wrote:
>
> On Fri, Jul 12, 2013 at 5:55 PM, Joshua Landau <joshua at landau.ws> wrote:
>
>> Au contraire, if you accept ½ you are bound by law to accept all of the
>> other fractions -- that's much more code than just allowing ∞.
>
>
> Let's see:
>
> def float(x):
> if x == '\u221e':
> return builtins.float('inf')
> return builtins.float(x)
>
> def float(x):
> if len(x) == 1:
> return unicodedata.numeric(x)
> return builtins.float(x)
>
> Where is "much more code "?
>
Sorry, I didn't equate you on this thread with you on the other, where you
said you wanted to special-case characters, I thought you were on about
solely fractions.
I don't like that idea, because then you could have stuff like ➉, ㊹, Ⅶ and
so on, leading people to assume that "𐌢Ⅴ" or somesuch is valid.
Additionally, accepting "ⅿ" is confusing, "⑽" is ridiculous and ↂ is just
silly. And why would int("𐌣") equal 50? Additionally, your change would
affect both int and float, and require an extra check to see whether the
return is an integer for int.
I see no advantage in a blatant explosion of acceptable characters, and
several disadvantages from having characters special-cased.
And if you accept '∞', aren't you "bound by law to accept '+∞' and '-∞' as
> well?
>
Yes. On the basis that we except "-inf", there's really no question. The
"-" is undoubtedly dealt with semi-separately, though, so it shouldn't
change the amount we have to write.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130713/b7d8a6e1/attachment.html>
More information about the Python-ideas
mailing list