[Python-Dev] extended slicing again
Michael Hudson
mwh@python.net
17 Jun 2002 15:26:22 +0100
Email back.
Guido van Rossum <guido@python.org> writes:
> > The trouble is, there's no way to distinguish between
> >
> > l1[a:b:]
> > l1[slice(a,b)]
> >
> > I deliberately made the former be the same as l1[a:b:1] (and so have the
> > restriction on the length of slice) to reduce special-casing (both for
> > the user and me). Do you think I got that wrong?
>
> Yes I think you got that wrong. __getslice__ and __setlice__ are
> being deprecated (or at least discouraged), so you'll have objects
> implementing only __getitem__. Such objects will get a slice object
> passed to __getitem__ even for simple (one-colon) slices. If such an
> object wants to pass the slice on to a list object underlying the
> implementation, it should be allowed to.
>
> IOW slice(a, b, None) should be considered equivalent to L[a:b] in all
> situations.
OK. I'll do this soon. It's not as bad as I thought at first -- only
mutable sequences are affected, so it's only lists and arrays that
need to be tweaked.
Cheers,
M.
--
Our lecture theatre has just crashed. It will currently only
silently display an unexplained line-drawing of a large dog
accompanied by spookily flickering lights.
-- Dan Sheppard, ucam.chat (from Owen Dunn's summary of the year)