I'm handling large numerical arrays in python through a GUI. I'd like to expose the slicing capabilities to a textbox in a GUI, so I can easily choose part of the array that should be used for the calculation at hand.
Simple example of what I'd like to do:
arr = array([0, 10, 20, 30, 40, 50, 60, 70, 80, 90])
a = "2:4" # example string from GUI Textbox
b = "[3, 4, 5]" # example string from GUI Textbox
print arr[a] # not valid code -> what should be written here to make it work?
print arr[b] # not valid code -> what should be written here to make it work?
should output:
[20, 30]
[30, 40, 50]
I found out about the slice function, but I'd need to parse my string manually and create a slice. Is there a simpler way?