Method(s) called by square brackets, slice objects

John Ladasky john_ladasky at sbcglobal.net
Thu Apr 10 14:52:31 EDT 2014


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.

OK, I think that I've got all that sorted out!



More information about the Python-list mailing list