[Python-Dev] (no subject)
Guido van Rossum
guido@python.org
Mon, 17 Jun 2002 09:39:59 -0400
> 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.
--Guido van Rossum (home page: http://www.python.org/~guido/)