Why can't slice use non-int. indices?

Alex Martelli aleaxit at yahoo.com
Thu May 31 18:17:20 EDT 2001


"Paul Winkler" <slinkp23 at yahoo.com> wrote in message
news:3B168CF7.F44777F9 at yahoo.com...
    ...
> How hard / desirable would it be to remove this (undocumented?)
> restriction from python? This could be 100% backwards compatible

It's not undocumented:
http://www.python.org/doc/2.0/ref/slicings.html
"The lower and upper bound expressions, if present, must
evaluate to plain integers".

It might still be worth easing this restriction, but it
is a documented one.  You can get a general slice
object with builtin function slice -- that one has no
type limitation on its arguments -- but not with
slicing syntax.

> Should I submit a PEP or just live with it?

To quote the timbot, a PEP is always a good thing.


Alex






More information about the Python-list mailing list