[Python-ideas] Yet another sum function (fractions.sum)

random832 at fastmail.us random832 at fastmail.us
Wed Aug 21 18:19:07 CEST 2013


On Wed, Aug 21, 2013, at 10:45, Stephen J. Turnbull wrote:
> random832 at fastmail.us writes:
> 
>  > 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.
> 
> That's precisely why you want an exception: to terminate the
> computation as soon as the unexpected condition can be detected.

Isn't that unpythonic? I mean, it's like doing type checking to make
sure the object you're passed doesn't implement only half of the duck
type you want (or none of a duck type the consumer of a list you're
adding it to wants, etc), and we just had a discussion about that (might
have been on python-list).

Also, not wanting complex numbers seems to me like not wanting negative
numbers, but we don't have a positive-subtract function that raises an
exception if a<b.


More information about the Python-ideas mailing list