"Ron Adam" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Terry Reedy wrote: >> "Ron Adam" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >>>So how do I express a -0? >> >> >> You just did ;-) but I probably do not know what you mean. > > b[-1:] = ['Z'] # replaces last item > b[-1:-0] = ['Z'] # this doesn't work > > If you are using negative index slices, you need to check for end > conditions because you can't address the end of the slice in a > sequential/numerical way.
OK, now I understand your question, the answer 'get a one's complement machine', and your point that without a -0 separate from +0, there is a subtle asymmetry that is easy to overlook. >> As I posted before (but perhaps it arrived after you sent this), one >> number >> indexing rounds down, introducing a slight asymmetry. > > I didn't see that one, Perhaps you did not see my other long post, where I drew ascii pictures? In brief: if you draw an axis with ticks, label the tick with ints, and put chars or item references in the space *between* the ticks, then the 'average' coordinate of the stuff between is n.5. The slice interval is n:(n+1), but a single int label has to be either n or (n+1), rounding down or up. And both choices have been made because both have advantages. In the US (and UK?), the ground level floor of a multifloor building is the first floor. In continental Europe (all or just some?), the ground floor is the ground (effectively zeroth) floor while the first floor up is the first stage (resting place on the stairway). > I don't think people would miss negative strides much if they were > removed. Replacing these case's with reverse() methods shouldn't be that > difficult. Yes, the introduction of reversed partly obsoleted the use of negative strides, at least outside of its numerical array origin. Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list