Bug in string.find; was: Re: Proposed PEP: New style indexing,was Re: Bug in slice type

Steve Holden steve at holdenweb.com
Sun Aug 28 22:58:30 CEST 2005

Bryan Olson wrote:
> Steve Holden wrote:
>  > Paul Rubin wrote:
>  > We are arguing about trivialities here. Let's stop before it gets
>  > interesting :-)
> Some of us are looking beyond the trivia of what string.find()
> should return, at an unfortunate interaction of Python features,
> brought on by the special-casing of negative indexes. The wart
> bites novice or imperfect Python programmers in simple cases
> such as string.find(), or when their subscripts accidentally
> fall off the low end. It bites programmers who want to fully
> implement Python slicing, because of the double-and-
> contradictory- interpretation of -1, as both an exclusive ending
> bound and the index of the last element. It bites documentation
> authors who naturally think of the non-negative subscript as
> *the* index of a sequence item.
Sure. I wrote two days ago:

> We might agree, before further discussion, that this isn't the most 
> elegant part of Python's design, and it's down to history that this tiny 
> little wart remains.

While I agree it's a trap for the unwary I still don't regard it as a 
major wart. But I'm all in favor of discussions to make 3.0 a better 

Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC             http://www.holdenweb.com/

More information about the Python-list mailing list