I'm trying to slice a numpy array using a slice that is predefined in a variable. This works:
b = fromfunction(lambda x,y: 10*x+y, (5,4),dtype=int) # Just some matrix
b[1:3,1:3]
# Output:
# array([[11, 12],
# [21, 22]])
But what I want to do is somthing like this:
slice = "1:3,1:3"
b[slice]
# Output:
# array([[11, 12],
# [21, 22]])
It is not important to me what type the slice-variable has, I'm just using a string as an example. How do I save a slice-specifier like that?