flatten a level one list

Sion Arrowsmith siona at chiark.greenend.org.uk
Thu Jan 12 07:53:17 EST 2006


In article <7x8xtlq03t.fsf at ruckus.brouhaha.com>,
Paul Rubin  <http://phr.cx@NOSPAM.invalid> wrote:
>Robin Becker <robin at SPAMREMOVEjessikat.fsnet.co.uk> writes:
>> >>>>>reduce(operator.add,a)
>> ...
>That's what I hoped "sum" would do, but instead it barfs with a type
>error.  So much for duck typing.

sum(...)
    sum(sequence, start=0) -> value

If you're using sum() as a 1-level flatten you need to give it
start=[].

-- 
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
  ___  |  "Frankly I have no feelings towards penguins one way or the other"
  \X/  |    -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump



More information about the Python-list mailing list