Todd schrieb am 22.07.2018 um 21:03:
For basic slices, the normal "slice(start, stop, step)" syntax works well. But it becomes much more verbose to create more complicated slices that you want to re-use for multiple multidimensional data structures, like numpy, pandas, xarray, etc.
One idea I had was to allow creating slices by using indexing on the slice class. So for example:
x = slice[5:1:-1, 10:20:2, 5:end]
Would be equivalent to:
x = (slice(5, 1, -1), slice(10, 20, 2), slice(5, None))
Note that this wouldn't be done on a slice instance, it would be done on the slice class. The basic idea is that it would simply return whatever is given to __getitem__.
Personally, I always likes that idea, but it would be worth looking up the previous discussions in the list archive to find out if they lead to any conclusion. AFAICT, "slice.literal" was the latest such proposal that was discussed.