[Python-ideas] Intermediate Summary: Fast sum() for non-numbers
Stefan Behnel
stefan_ml at behnel.de
Wed Jul 17 20:07:09 CEST 2013
M.-A. Lemburg, 15.07.2013 09:11:
> I don't understand why people try to use sum() for anything
> other than a sequence of numbers.
>
> If you want to flatten a list, use a flatten function.
+1
And, while we're at it, we can just as well ask why
sum([[1,2,1], [2,1,2], [3,4,5,[6,7]], [[4,3], 1]])
doesn't return 42. IMHO, this would make a lot more sense than returning a
concatenated list.
Stefan
More information about the Python-ideas
mailing list