for / while else doesn't make sense

Chris Angelico rosuav at gmail.com
Mon May 23 14:14:37 EDT 2016


On Tue, May 24, 2016 at 3:57 AM, Jon Ribbens
<jon+usenet at unequivocal.co.uk> wrote:
> On 2016-05-23, Chris Angelico <rosuav at gmail.com> wrote:
>> On Tue, May 24, 2016 at 3:09 AM, Jon Ribbens
>><jon+usenet at unequivocal.co.uk> wrote:
>>> On 2016-05-23, Steven D'Aprano <steve at pearwood.info> wrote:
>>>> But one thing is certain: very few people, Jon Ribbens being one of them,
>>>> expects 1/3 to return 0. And that is why Python changed the meaning of
>>>> the / operator: because using it for integer division was deeply unpopular
>>>> and a bug magnet.
>>>
>>> Making it return floats is also a bug magnet, just for more subtle
>>> bugs that are harder to diagnose.
>>
>> See my earlier post. There are four broadly-viable options: int,
>> float, Fraction, Decimal. *Every one of them* is a bug magnet in one
>> way or another. Which kind of bug would you like?
>
> The simplest one - isn't that obvious from what I've already said?

Gotcha. You're advocating Fraction, which has no bugs whatsoever. Of
course, it doesn't give you any more numbers than int gives you [1],
but at least it doesn't restrict you to crazy things like only
fifty-three significant digits [2] in its binary representation. And
it's really easy to work with; performance is predictable (it's just
two integers, and we know that the performance of integers is
predictable), and they're easy to eyeball.

ChrisA

[1] Rationals and integers are both "countably infinite" - there are
as many of each as there are counting numbers, odd numbers, prime
numbers, squares, Fibonacci numbers, and dates in the Julian calendar.
And dates that nerds didn't get because they were too busy proving
which things are countably infinite and which aren't.
[2] The number of the Love Bug. This is probably significant.



More information about the Python-list mailing list