[Python-ideas] Yet another sum function (fractions.sum)
MRAB
python at mrabarnett.plus.com
Wed Aug 21 19:06:07 CEST 2013
On 21/08/2013 15:19, random832 at fastmail.us wrote:
> On Tue, Aug 20, 2013, at 18:47, Andrew Barnert wrote:
>> So instead of math.sqrt and cmath.sqrt, we just have one function that
>> decides whether sqrt(-1) is 0+1j or an exception based on guessing
>> whether you wanted complex numbers? :)
>
> Why exactly is an exception reasonable? If you don't want complex
> numbers, don't take square roots of negative numbers. If you can't
> handle complex numbers, you'll get an exception down the line anyway.
>
I think a simpler rule might be: if the argument is a float then the
result is a float; if the argument is complex then the result is
complex.
If that's the case, then do we really need to keep them separate,
having math and cmath?
More information about the Python-ideas
mailing list