I have created a multidimensional array in Python like this:
self.cells = np.empty((r,c),dtype=np.object)
Now I want to iterate through all
It may be also worth to mention itertools.product().
cells = [[x*y for y in range(5)] for x in range(10)]
for x,y in itertools.product(range(10), range(5)):
print("(%d, %d) %d" % (x,y,cells[x][y]))
It can create cartesian product of an arbitrary number of iterables:
cells = [[[x*y*z for z in range(3)] for y in range(5)] for x in range(10)]
for x,y,z in itertools.product(range(10), range(5), range(3)):
print("(%d, %d, %d) %d" % (x,y,z,cells[x][y][z]))