In python, we can use range(x)
to traverse from 0
to x-1
. But what if I want to traverse a high-order range? For example, given (a, b)
, I want to traverse all (x1, x2)
such that 0 <= x1 < a, 0<= x2 < b
. If the dimension is fixed, then it's easy, say it's k-dimension (in the example I gave, k is 2), then we can simply hard-code k loops to achieve it, but how about when the dimension is also a variable? Is there any elegant pythonic way to handle this?