Suppose I have a matrix composed of a list of lists like so:
>>> LoL=[list(range(10)) for i in range(10)] >>> LoL [[0, 1, 2, 3, 4, 5, 6, 7,
I dont know if its easier, but let me throw an idea to the table:
from itertools import product r = (1+1, 4+1) s = (2+1, 5+1) array = [LoL[i][j] for i,j in product(range(*r), range(*s))]
This is a flattened version of the submatrix you want.