[docs] Possible bug in 3.2 Accumulate Function

Frank Ellis silleknarf at hotmail.com
Sun Dec 5 19:14:31 CET 2010

Quoting from the http://docs.python.org/dev/py3k/whatsnew/3.2.html page:
The itertools module has a new function, accumulate() modeled on APL’s scan operator and on Numpy’s accumulate function:>>> list(accumulate(8, 2, 50))
[8, 10, 60]
>>> prob_dist = [0.1, 0.4, 0.2, 0.3]
>>> list(accumulate(prob_dist))      # cumulative probability distribution
[0.1, 0.5, 0.7, 1.0]                                                                       I'm not sure if this is a bug as I'm not sure if this is how the function actually behaves. Should the first function not take a list? For example:>>> list(accumulate([8, 2, 50]))
[8, 10, 60]Notice the square brackets. I have not actually tested the function personally but it seems like something worth noting.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20101205/3de36e89/attachment.html>

More information about the docs mailing list