reduce to be removed?

Virgil Dupras hardcoded.software at gmail.com
Sat Nov 11 17:52:50 EST 2006


Dustan wrote:
> According to the following page on Wikipedia:
> http://en.wikipedia.org/wiki/Python_%28programming_language%29#Future_development
> reduce is going to be removed in python 3.0. It talks of an
> accumulation loop; I have no idea what that's supposed to mean. So,
>
> ===============================
> >>> x =\
> [[1,2,3],
>  [4,5,6],
>  [7,8,9]]
> >>> reduce(lambda a,b:a+b,  x,  [])
> [1, 2, 3, 4, 5, 6, 7, 8, 9]
> ===============================
>
> What's an accumulation loop, and how would I convert this code so it's
> compatible with the future 3.0 (preferably in a short sweet expression
> that I can embed in a list comprehension)?

itertools.chain or sum(x,[])




More information about the Python-list mailing list