# [Python-Dev] Fwd: summing a bunch of numbers (or "whatevers")

**Brett Cannon
**
drifty@alum.berkeley.edu

*Sun, 20 Apr 2003 01:18:08 -0700 (PDT)*

[Alex Martelli]
>* On Sunday 20 April 2003 08:09 am, Prabhu Ramachandran wrote:
*<snip> ...
>* In the context of Numeric use, it's quite appropriate to have sum,
*prod,
>* and the other ufuncs' reduce AND accumulate methods. In everyday
*>* programming in other fields, the demand for the functionality given by
*>* sum is FAR higher than that given by prod.
*<snip>
I think part of the trouble here is the name. The word "sum" just
automatically causes one to think math. This leads to thinking of
multiplication, division, and subtraction. But Alex's proposed function
does more than a summation by special-casing the concatentation of
strings.
Perhaps renaming it to something like "combine()" would help do away with
the worry of people wanting a complimentary version for multiplication
since it does more than just sum numbers; it also combines strings in a
very efficient manner. I mean we could extend this to all built-in types
where there is a reasonable operation for them (but this is jumping the
gun).
And as for the worry about this being a built-in, we do have divmod for
goodness sakes. I mean divmod() is nothing more than glorifying division
and remainder for the sake of clean code; ``divmod(3,2) == (3/2, 3%2)``.
This function serves the same purpose in the end; to allow for cleaner
code with some improved performance for a function that people use on a
regular enough basis to ask for it constantly on c.l.p .
-Brett