sum for sequences?

Paul Rubin no.email at nospam.invalid
Wed Mar 24 19:19:19 EDT 2010


kj <no.email at please.post> writes:
> 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)

use itertools.chain for this.  A few people have mentioned that sum will
also work, but I think for that purpose it could have O(n**2)
complexity.



More information about the Python-list mailing list