[Python-ideas] Why does `sum` use a default for the `start` parameter?

MRAB python at mrabarnett.plus.com
Sat Dec 5 19:18:08 CET 2009

Ram Rachum wrote:
>> There is a choice between these two variants:
>> a) require start for non-numerical sequences
>> b) require start for possibly empty sequences
>> I don't have a preference for either, so for compatibility's sake I would
>> vote to keep the current one, which is a).  It also stands to reason that
>> buggy usage in case b) is harder to detect, since the common case will
>> not uncover the bug (the sequence being nonempty), while for case a) it does.
> I prefer (b). The problem with requiring `start` for sequences of non-numerical 
> objects is that you now have to go out and create a "zero object" of the same
> type as your other objects. The object class might not even have a concept of a 
> "zero object".
If the objects can be summed, shouldn't there also be a zero object?
Does anyone have an example when that's not possible?

More information about the Python-ideas mailing list