I am trying to access systematically a numpy array's axis. For example, suppose I have an array
a = np.random.random((10, 10, 10, 10, 10, 10, 10))
# choosing 7:9 from axis 2
b = a[:, :, 7:9, ...]
# choosing 7:9 from axis 3
c = a[:, :, :, 7:9, ...]
Typing colons gets very repetitive if I have a high dimensional array. Now, I want some function choose_from_axis such that
# choosing 7:9 from axis 2
b = choose_from_axis(a, 2, 7, 9)
# choosing 7:9 from axis 3
c = choose_from_axis(a, 3, 7, 9)
So, basically, I want to access an axis with a number. The only way I know how to do this is to use rollaxis back and forth, but I am looking for a more direct way to do it.