How can I resolve this?
>>> class unslice:
... def __getitem__(self, item): print type(item), ":", item
...
>>> u = unslice()
>>> u[1,2] # using an extended slice
<type 'tuple'> : (1, 2)
>>> t = (1, 2)
>>> u[t] # or passing a plain tuple
<type 'tuple'> : (1, 2)
Rational:
I'm currently overengineering a sorted associative collection with the ability to return ranges of items. It is quite likely that I will want to store tuples of small integers (or even more pathologically wierd values like Ellipsis) in the collection (as keys), and will need some kind of sane way of differentiating extended slices from plain keys
In the one-dimensional case, it's sort of a non-issue. I can't think of any real reason I would want to collect values of type slice
, especially since xrange
values are functionally similar and more recognizable to pythonistas (in my judgement). All other extended slice constructs are tuples of slice
, Ellipsis
or plain-old python values
No other type of extended slice seems to be in common use for any kind of collection except multidimensional arrays as in NumPy.
I do need to support n-dimensional axes, similar to oct-trees or GiS indices.