Negative array indicies and slice()

Ian Kelly ian.g.kelly at gmail.com
Tue Oct 30 04:15:23 EDT 2012


On Mon, Oct 29, 2012 at 5:54 PM, Andrew Robinson
<andrew3 at r3dsolutions.com> wrote:
>> I don't know of a reason why one might need to use a negative start
>> with a positive stop, though.
>
> I've already given several examples; and another poster did too

I meant that I don't know of a reason to do that given the existing
semantics, which is what you were asking for.  :-)

I understand and agree that there are potential applications for
allowing slices to wrap around from negative to positive.  What I'm
not convinced of is that these applications need or should be handled
by the slicing operation -- which is more commonly understood as
producing subsequences -- especially since they already can be handled
relatively easily by iteration.  I think that more users would find
the behavior surprising than useful.



More information about the Python-list mailing list