SyntaxFix
Write A Post
Hire A Developer
Questions
If you only need the indices, you could try numpy.ndindex:
numpy.ndindex
>>> a = numpy.arange(9).reshape(3, 3) >>> [(x, y) for x, y in numpy.ndindex(a.shape)] [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)]