You can use itertools.product :
In [16]: from itertools import product In [17]: values = list(product(range(4), range(4), range(11))) In [18]: values[:5] Out[18]: [(0, 0, 0), (0, 0, 1), (0, 0, 2), (0, 0, 3), (0, 0, 4)] In [19]: values[-5:] Out[19]: [(3, 3, 6), (3, 3, 7), (3, 3, 8), (3, 3, 9), (3, 3, 10)]
Given an array of ranges, you can do something like the following. (I used a couple of non-zero low values to demonstrate the general case - and reduce the size of the output. :)
In [41]: ranges = np.array([[0, 3], [1, 3], [8, 10]]) In [42]: list(product(*(range(lo, hi+1) for lo, hi in ranges))) Out[42]: [(0, 1, 8), (0, 1, 9), (0, 1, 10), (0, 2, 8), (0, 2, 9), (0, 2, 10), (0, 3, 8), (0, 3, 9), (0, 3, 10), (1, 1, 8), (1, 1, 9), (1, 1, 10), (1, 2, 8), (1, 2, 9), (1, 2, 10), (1, 3, 8), (1, 3, 9), (1, 3, 10), (2, 1, 8), (2, 1, 9), (2, 1, 10), (2, 2, 8), (2, 2, 9), (2, 2, 10), (2, 3, 8), (2, 3, 9), (2, 3, 10), (3, 1, 8), (3, 1, 9), (3, 1, 10), (3, 2, 8), (3, 2, 9), (3, 2, 10), (3, 3, 8), (3, 3, 9), (3, 3, 10)]
If the low values of all ranges are 0, you can use np.ndindex :
In [52]: values = list(np.ndindex(4, 4, 11)) In [53]: values[:5] Out[53]: [(0, 0, 0), (0, 0, 1), (0, 0, 2), (0, 0, 3), (0, 0, 4)] In [54]: values[-5:] Out[34]: [(3, 3, 6), (3, 3, 7), (3, 3, 8), (3, 3, 9), (3, 3, 10)]