To generalize to ndim inputs, Create a pytuple of out_ndim, then set all elemwise to full_slice except the slice_tuple[axis] that you set to section_slice.