[Tutor] Hiding Superclass Methods

Adam Bark adam.jtm30 at gmail.com
Tue Oct 12 02:36:59 CEST 2010

On 11/10/10 23:52, Steven D'Aprano wrote:
> On Tue, 12 Oct 2010 01:55:10 am Adam Bark wrote:
>> On 11/10/10 15:29, Denis Gomes wrote:
>>> Thank you both for your responses.  I do have one other question if
>>> I use the method both of you describe. How do I go about
>>> implementing slicing and indexing for an object in python?  A list
>>> object innately has them and that is really why I wanted to use it.
>>>   I would appreciate it if you can point me to something.
>>> Denis
>> You can use __getslice__, __setslice__ etc. methods. They're detailed
>> in the list docstrings. Here's an example of using __getslice__
> __getslice __setslice__ and __delslice__ have been deprecated since
> version 2.0, seven versions ago.
> http://docs.python.org/reference/datamodel.html#object.__getslice__
> You should use __getitem__ __setitem__ and __delitem__, and detect if
> your argument is an integer or a slice object, and behave accordingly.
> http://docs.python.org/reference/datamodel.html#object.__getitem__
Oh right, 2.6 doesn't say anything about it in the docstrings.

More information about the Tutor mailing list