> > from numpy import s_ > > s_[1:2:3] > slice(1, 2, 3) > > s_[1:2:3, ..., 4:5] > (slice(1, 2, 3), Ellipsis, slice(4, 5, None)) > > Or would it be possible to define "slice" itself so that it implements > __getitem__ and __getslice__?
Indeed! Python 2.6.4 (r264:75706, Oct 27 2009, 06:25:13) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> class slice(object): ... @staticmethod ... def __getitem__(sliceobj): ... return sliceobj >>> slice = slice() >>> slice[:] slice(None, None, None) >>> slice[1::-1] slice(1, None, -1) >>> range(10).__getitem__(slice[::2]) [0, 2, 4, 6, 8] ----aht -- http://mail.python.org/mailman/listinfo/python-list