aleax at aleax.it
Thu Jun 19 18:54:12 CEST 2003
Steve McAllister wrote:
>> Python is not Perl! If you need to build the sum over a sequence of
>> strings containing numbers
>> then you need to convert them to numbers.
> I am talking about sum(['x', 'y']) -> 'xy'.
> Since strings can be added, they should be sumable too. No? :-)
Nope. I thought so too, originally, and went out of my way in order
to let sum accept a sequence of strings (and deal with them rapidly,
just like ''.join does, of course) in the very first prototype of
sum. This caused a real mess when conjoined with such issues as
summing empty sequences and summing non-restartable iterators. The
knot was elegantly cut by Guido, who Pronounced that sum wanted to
be only and specifically about numbers -- and I think that, as is
the case more often than not, he was right.
More information about the Python-list