On 2012-12-04, Hans Mulder <han...@xs4all.nl> wrote: > It's considered bad style to use map it you don't want the list it > produces. > >> There are more ways: >> >>>>> from operator import add >>>>> reduce(add, a) >> (1, 2, 3, 4) > > There's a built-in that does "reduce(operator.add"; it's called "sum": > >>>> sum(a, ()) > (1, 2, 3, 4)
I thought that sort of thing would cause a warning. Maybe it's only for lists. Here's the recipe from the itertools documentation: def flatten(listOfLists): "Flatten one level of nesting" return chain.from_iterable(listOfLists) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list