Why Python 3?

Chris Angelico rosuav at gmail.com
Mon Apr 21 00:48:34 EDT 2014


On Mon, Apr 21, 2014 at 1:43 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
>> Both explicit forms can be done cleanly without empowering the language
>> with the magic of int/int->float.
>
> It's hardly magic, and I really am having difficult in working out
> exactly what your objection to it is. Is it really as simple as
> "operations on ints should only return ints, like in C"?

All other basic arithmetic operations on two numbers of the same type
results in another number of that type. You wouldn't expect the
product of two Fractions to be a Decimal, nor the sum of two complex
numbers be a float (even if it results in an imaginary part of zero,
it'll still be a complex: (1+2j) + (2-2j) --> (3+0j) not 3.0). There's
just one special case: dividing an integer by an integer yields a
float, if and only if you use truediv. It sticks out as an exception.

ChrisA



More information about the Python-list mailing list