Testing if an index is in a slice

ajaksu ajaksu at gmail.com
Sun Jan 4 08:46:42 CET 2009

On Jan 3, 8:53 pm, Bryan Olson <fakeaddr... at nowhere.org> wrote:
> If we add a parameter for the length of the list to which the slice is
> applied, then inslice() is well-defined.


> I thought it would easy to write,

Heh, I gave up on the example I mentioned above :)

> but that was hours ago when I knew
> less about Python slice indexing than I do now. And I thought I new a
> bunch from writing a virtual slice class.

Maybe you could write about what you learned in the docs?

> I'm leaning towards mmanns' idea that this should be built in. Handling
> all the cases is remarkably tricky.

Even without testing your code, I agree. I suggest that you add this
as a feature request to the tracker at http://bugs.python.org/. I hope
Raymond Hettinger likes it and adds an islice version :)

More information about the Python-list mailing list