sum for sequences?

Glazner yoavglazner at gmail.com
Wed Mar 24 16:39:10 CET 2010


On Mar 24, 5:29 pm, kj <no.em... at please.post> wrote:
> Is there a sequence-oriented equivalent to the sum built-in?  E.g.:
>
>   seq_sum(((1, 2), (5, 6))) --> (1, 2) + (5, 6) --> (1, 2, 5, 6)
>
> ?
>
> (By "sequence" I'm referring primarily to lists and tuples, and
> excluding strings, since for these there is ''.join()).
>
> TIA!
>
> ~K

try itertools.chain



More information about the Python-list mailing list