A suggestion for a possible Python module

Terry Reedy tjreedy at udel.edu
Wed Mar 5 00:13:17 EST 2003


"Alex Martelli" <aleax at aleax.it> wrote in message
news:oK49a.5039$zo2.154480 at news2.tin.it...
> Yes, and the boundaries play strangely...:
>
> >>> x = list('arrivederci')
> >>> x[2:7] = x[7:2:-1]
> >>> ''.join(x)
> 'aredevierci'
> >>>
>
> x[2:7] being 'rived', one would expect 'ardevirerci' -- but to
> get that one needs an ample application of -1's, alas...:
>
> >>> x = list('arrivederci')
> >>> x[2:7] = x[7-1:2-1:-1]
> >>> ''.join(x)
> 'ardevirerci'
> >>>
>
> Goofy, slow, and error-prone, I think there's little to be said
> for this idiom (x[start:stop] = x[stop-1:start-1:-1] in the
> general case).

As near as I can tell, the 19 February 2003 2.3a2 Ref Man, Section
5.3.3 Slicings, (on python.org) has not been updated to specify the
long_slice behavior when *not* used as a dict key but used for seq
access.  If so, there is no way to tell if behavior above is intended
or is a bug (except by analogy with Numeric behavior, which I am not
familiar with).

Terry J. Reedy






More information about the Python-list mailing list