A suggestion for a possible Python module

Terry Reedy tjreedy at udel.edu
Wed Mar 5 11:07:42 EST 2003


"Jp Calderone" <exarkun at intarweb.us> wrote in message
news:mailman.1046876115.32389.python-list at python.org...
> On Wed, Mar 05, 2003 at 12:24:10AM -0500, Terry Reedy wrote:
> > s.reverse([i[,j]])     reverses the items of s[i:j] in place
within s (6) (10)
> > <and add, subject to footnote renumbering>
> > 10
> >        The optional arguments i and j act like slice bounds and
> > default to 0 and len(s).  The default with no arguments reverses
the
> > entire sequence.

>   Do you plan to support negative indices?

Good question.  For myself, yes:  I want that s.reverse(i,j) be
semantically equal to

tem = s[i:j]
tem.reverse()
s[i:j] = tem

No new rules to learn.

I considered the possibility of a third (step) param, but rejected
such so far because a) I don't know if s[i:j:k] = whatever is legal
and b) I have not been able to think of any real use case, let alone
one that would justify the added complexity.

Terry J. Reedy






More information about the Python-list mailing list