On 4/10/2014 2:52 PM, John Ladasky wrote:
Thanks to both Ethan and Steven for their replies.

Steven: I was trying to use the interpreter and wasn't getting results that I 
understood -- because I didn't know that __getslice__ was simply gone in Python 
3.  I implemented a __getslice__ method in my subclass that never got called.

Ethan: I saw that slice objects were being sent to __getitem__, but that 
confused me as I thought that its purpose, as implied by the method name, was 
to return a SINGLE item.

A slice is a single sequence object. Sequences can result from any of index lookup, key lookup, or slicings.

The backstory is that slicing originally supported only start and stop positions. The 3 __xyzslice__ had separate start and stop parameters instead of the 1 index/key parameter of __xyzitem__. Strides and the slice class were introduced for the benefit of numerical python. When they were 'mainstreamed' into regular python, the __xyzslice__ methods were deprecated (in 2.0) as a single slice object can just as well be passed to __xyzitem__.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to