[issue7176] sum() doesn't work for lists.

Raymond Hettinger report at bugs.python.org
Tue Oct 20 21:19:21 CEST 2009


Raymond Hettinger <rhettinger at users.sourceforge.net> added the comment:

One use of the start argument is used to specify an initial zero/metpy
value for the summation:  0  or  0.0   or Decimal(0)  or  [].

BTW, sum() isn't a good technique for concatenating lists.  Instead use
something like:

   result = []
   for seq in data:
      result.extend(seq)

A fast one-liner version:
   result = list(itertools.chain.from_iterable(seq))

----------
nosy: +rhettinger

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7176>
_______________________________________


More information about the Python-bugs-list mailing list