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__ -- Steven D'Aprano _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor