Can python's slice notation be used outside of brackets?
问题 Within brackets, python's slice shorthand auto-generates tuples of slice objects: class Foo(object): def __getitem__(self, key): print key Foo()[1::, 2:20:5] This prints (slice(1, None, None), slice(2, 20, 5)) . As far as I can tell, however, this shorthand doesn't work outside brackets. Is there any way to use slice shorthand in other contexts? I could define a dummy object that simply returns whatever it is passed to __getitem__ -- that would at least give me a way to generate slice tuples