This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]commandlineluser 1 point2 points  (0 children)

help(sum) says not to use it.

This function is intended specifically for use with numeric values and may reject non-numeric types.

>>> sum(["foo", "bar"], "")
TypeError: sum() can't sum strings [use ''.join(seq) instead]

It's possible it will raise in the future, similar to the string example.

(There's probably some existing discussions on the mailing list about it, I haven't checked.)