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

Joshua Landau joshua at landau.ws
Sun Jul 14 08:40:52 CEST 2013


On 14 July 2013 03:17, Alexander Belopolsky
<alexander.belopolsky at gmail.com> wrote:
>
> On Sat, Jul 13, 2013 at 9:24 PM, Steven D'Aprano <steve at pearwood.info>
> wrote:
>>
>> Or even having literal ∞ recognised as float('inf')
>
>
> BTW, if having literal ∞ was considered as a language feature [1], I would
> support it:
>
> if x == ∞: ...
>
> would be an improvement over existing alternatives
>
> if x == float('inf'): ...
>
> or
>
> if math.isinf(x): ...
>
> But float('∞') still looks like line noise.

I disagree. Personally, code in which copy-paste is the best way to
write single-character identifiers is a hassle. I know because I
wrote:

from itertools import count as æ, permutations as Æ, starmap as ð
[globals().setdefault("%c"%sum(ø.encode()),ß)for ø,ß in
vars(__builtins__).items()if ø!="vars"]
sorted = lambda ħ:ƿ(ƞ for ı in
φ(ƴ(lambda:ħ,æ),ń(0,ń(ħ)**(len(ħ)*2-1)*len(ħ)))for ƞ in Æ(ħ)if
ǂ(()).__eq__((ŕ(ð(ǂ(Ƽ(ƞ).pop()).__rpow__,φ(ŕ(œ(ƞ,ƴ(lambda:0,ħ)),()),1))),ħ),ı))[::-1]

And that was a *nightmare* to edit.


More information about the Python-ideas mailing list