[Python-Dev] sum(...) limitation

Antoine Pitrou antoine at python.org
Sat Aug 9 07:39:16 CEST 2014

Le 09/08/2014 01:08, Steven D'Aprano a écrit :
> On Fri, Aug 08, 2014 at 10:20:37PM -0400, Alexander Belopolsky wrote:
>> On Fri, Aug 8, 2014 at 8:56 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
>>> I don't use sum at all, or at least very rarely, and it still irritates me.
>> You are not alone.  When I see sum([a, b, c]), I think it is a + b + c, but
>> in Python it is 0 + a + b + c.  If we had a "join" operator for strings
>> that is different form + - then sure, I would not try to use sum to join
>> strings, but we don't.
> I've long believed that + is the wrong operator for concatenating
> strings, and that & makes a much better operator. We wouldn't be having
> these interminable arguments about using sum() to concatenate strings
> (and lists, and tuples) if the & operator was used for concatenation and
> + was only used for numeric addition.

Come on. These arguments are interminable because many people (including 
you) love feeding interminable arguments. No need to blame Python for that.

And for that matter, this interminable discussion should probably have 
taken place on python-ideas or even python-list.



More information about the Python-Dev mailing list