I would like to create an index in the form of
[:, :, :, 0, :, :, :, :]
where the position of 0
is determined by a variable, say axis
to slice a NumPy array. Obviously there are two special cases that are easy to treat:
axis = 0
would be equivalent to[0, ...]
axis = -1
would be equivalent to[..., 0]
But I wonder how this can be done for any axis
value?