On Tue, 10 Apr 2007 09:51:45 -0600, Steven Bethard <[EMAIL PROTECTED]> wrote: >Jean-Paul Calderone wrote: >> On Tue, 10 Apr 2007 08:35:56 -0600, Steven Bethard >> <[EMAIL PROTECTED]> wrote: >>> Yes, you do still need to implement __getslice__ if you're subclassing >>> a class (like unicode or list) which provides it. The __getslice__ >>> method can't be removed entirely for backwards compatibility reasons >>> (though it is being removed in Python 3000). >> >> Why does this mean that the unicode type has to implement __getslice__? > >Because code could exist like:: > > >>> class C(list): > ... def __getslice__(self, start, stop): > ... return C(list.__getslice__(self, start, stop)) > ... > >>> type(C([1, 2, 3, 4])[:2]) > <class '__main__.C'> >
Ah, excellent point. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list