Using numpy.indices and numpy.stack
numpy.indices
numpy.stack
import numpy shape = (6,2,8,7) array_of_positions = numpy.stack(numpy.indices(shape), axis = len(shape))