import operator

def accumulate(iterable, func=operator.add):
    """Return running totals"""
it = iter(iterable)
total = next(it)
yield total
for element in it:
    total = func(total, element)
yield total
array = list(accumulate(rand(100)))
Понимание списка с аккумулятором