best cumulative sum

Erik Max Francis max at alcyone.com
Mon Nov 21 01:07:42 EST 2005


Micah Elliott wrote:

> On Nov 21, David Isaac wrote:
 >
>> What's the good way to produce a cumulative sum?
> 
>>>> import operator
>>>> x = 1,2,3
>>>> reduce(operator.add, x)
> 6

Or just sum(x).

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   Never contend with a man who has nothing to lose.
   -- Baltasar Gracian



More information about the Python-list mailing list