slice's indices() method

smichr at gmail.com smichr at gmail.com
Mon Oct 30 22:48:11 EST 2006


Fredrik Lundh wrote:
> smichr at gmail.com wrote:
>
> > Is there any reason not to change the behavior of the indices() method
> > so it gives indices that can be used in range (to give indices
> > corresponding to elements that would be extracted by a given slice)
> > *and* used as arguments for slices so that the slice with the new
> > indices (obtained from the indices() method) would extract the same
> > elements as the original slice from whence they were obtained?
>
> and this month's "absolutely most pointless of all pointless proposals"
> award goes to...
>
> </F>

I don't see the suggestion that much different than wanting the output
of a function like ord() to be able to be used again in str() to get
back a given character. There was some good conversation about the
indices method a year ago...I was hoping to get some useful feedback as
to why this might not be an improvement to the behavior of the slice's
indices() method.

Although you have not run into the need to get the specific indices
from a slice (and perhaps that's why you think it's pointless) I did
need them and got bitten by the non-round-trip-able behavior of the
indices() method...and ended up writing a workaround rather than being
able to use the built in method.

/chris




More information about the Python-list mailing list