Flatten lists
Flatten a Python list like so:
reduce(lambda x,y: x+y, [[1,2,3],[4,5,6], [7]])
Or quicker and neater using the operator library:
import operator reduce(operator.add, [[1,2,3],[4,5,6],[7]])
If the dimensions of the nested lists are regular, you can use numpy.ravel:
import numpy numpy.array([[0,1],[2,3],[4,5],[6,7]]).ravel()