[Python-Dev] sum(...) limitation
Stefan Behnel
stefan_ml at behnel.de
Sat Aug 2 17:06:10 CEST 2014
Alexander Belopolsky schrieb am 02.08.2014 um 16:52:
> On Sat, Aug 2, 2014 at 3:39 AM, Steven D'Aprano wrote:
>
>> String concatenation with + is an attractive
>> nuisance for many people, including some who actually know better but
>> nevertheless do it. Also, for reasons I don't understand, many people
>> dislike or cannot remember to use ''.join.
>
> Since sum() already treats strings as a special case, why can't it simply
> call (an equivalent of) ''.join itself instead of telling the user to do
> it? It does not matter why "many people dislike or cannot remember to use
> ''.join" - if this is a fact - it should be considered by language
> implementors.
I don't think sum(strings) is beautiful enough to merit special cased
support. Special cased rejection sounds like a much better way to ask
people "think again - what's a sum of strings anyway?".
Stefan
More information about the Python-Dev
mailing list