frobozz_electric at hotmail.com
Thu Jun 19 17:29:02 CEST 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?
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
and other related python-dev discussions
More information about the Python-list