sum(strings)

Sean Ross frobozz_electric at hotmail.com
Thu Jun 19 11:29:02 EDT 2003


"Steve McAllister" <nosp at m.needed> wrote in message
news:bcsjii$3vf$1 at alto.univ-mlv.fr...
> Why does sum reject strings?  Is it a matter of efficiency of the
> underlying implementation?
>

http://www.python.org/dev/summary/2003-04-16_2003-04-30.html
"""
Originally Alex [Martelli, who implemented sum(),] also wanted to
special-case the handling of a list of strings so as to prevent having to
tell new Python programmers that "".join(list_of_strings) is the best way to
concatenate a bunch of strings and that looping over them is really bad (the
amount of I/O done in the loop kills performance). But this special-casing
was shot down because it seemed rather magical and can still be taught to
beginners easily enough ('reduce' tends to require an understanding of
functional programming).
"""
Also see:
http://mail.python.org/pipermail/python-dev/2003-April/034854.html
and other related python-dev discussions







More information about the Python-list mailing list