17 Aug
2021
17 Aug
'21
11:11 a.m.
In addition to the other answers: Libraries like NumPy define a helper factory for slices, e.g. ```python
import numpy as np np.s_[1:10] slice(1, 10, None)
You can do the same in your library. Equally, you don't have to return a slice — you might want to return a "Range" object as mentioned by other posters.
Personally, I don't think there needs to be a more concise syntax — people rarely need bare slice objects by themselves.