
On Thu, 27 Jul 2000, Ka-Ping Yee wrote:
So, how about:
__get__(index, ...) # I want an ITEM. __getslice__(slice-object, ...) # I want a SLICE.
Addendum: For __set__ and __setslice__, since there may be a variable number of index arguments, it seems the value to set must *precede* the indices. The full interface: __get__(*indices) __set__(value, *indices) __del__(*indices) __getslice__(*slices) __setslice__(value, *slices) __delslice__(*slices) I prefer putting the indices last to passing in a tuple of indices for the following reasons: 1. It would be annoying and slightly slower to have to declare __get__((index,)) instead of __get__(index). 2. I want to encourage prediction of the number of indices. Since most multidimensional types are likely to have a fixed number of dimensions, it's better to have an interface look like, e.g. __get__(x, y, z) # Clearly a 3-dimensional array! instead of __get__(indices) # Don't know how many dimensions. The error is caught earlier, and the expectations of the programmer are more visible. To implement a variable number of dimensions, of course one can always write __get__(*indices) but this would not be the conventional thing to write: it would make clear that there is something special going on here. -- ?!ng