String negative indices?

Antoon Pardon apardon at forel.vub.ac.be
Mon Jun 26 08:59:37 EDT 2006


On 2006-06-23, Filip Wasilewski <filipwasilewski at gmail.com> wrote:
> drtimhill at comcast.net wrote:
>
>> Logically, I should be able to enter x[-2:-0] to get the last and next to last characters. However, since Python doesn't distinguish between positive and negative zero, this doesn't work. Instead, I have to enter x[-2:].
>
> Hooray! Logically there is no such thing as positive or negative zero,
> or did I miss something in the primary?
>
> PS. x[len(x)-2 : len(x)-0]

This seems to defeat the purpose of allowing negative indexes. My
understanding was that negative indexes were introduced to avoid
things like seq[len(seq) - i]

-- 
Antoon Pardon



More information about the Python-list mailing list