reduce to be removed?

George Sakkis george.sakkis at
Mon Nov 13 01:42:53 CET 2006

Dustan wrote:

> Alright, I can see I'm a bit outvoted here. I tried your suggestions
> and it worked fine.
> I'll also try to consider in the future that part of the problem might
> be lack of information conveyed on my part.

If you insist on one-liners, it can be done without sum(), though it
probably doesn't buy you much in readability:

from itertools import chain
[list(chain(*row)) for row in foo]

By the way, if this was not a toy example and you're doing serious work
with n-dimensional arrays, make yourself a favor and install NumPy;
it's usually both faster and more elegant for array manipulations than
pure python.


More information about the Python-list mailing list