Suppose I have a CLI and would like to construct a slice from the CLI, where the CLI user just inputs a range string.
r = '1:4:2'
axis = '2'
And I have a way of slicing this as follows:
arr = np.zeros((10,10,10))
sliced_arr = eval("arr["+','.join([':',':',r])+"]")
Question: is there a better way to do this?
evalis just about always better.axisever (meant to be) used?