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

Ram Rachum cool-rr at cool-rr.com
Sat Dec 5 19:05:59 CET 2009


> 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".

Ram.




More information about the Python-ideas mailing list