Bug in string.find; was: Re: Proposed PEP: New style indexing, was Re: Bug in slice type
Steve Holden
steve at holdenweb.com
Sat Aug 27 11:15:46 EDT 2005
Paul Rubin wrote:
> Steve Holden <steve at holdenweb.com> writes:
>
>>If you want an exception from your code when 'w' isn't in the string
>>you should consider using index() rather than find.
>
>
> The idea is you expect w to be in the string. If w isn't in the
> string, your code has a bug, and programs with bugs should fail as
> early as possible so you can locate the bugs quickly and easily. That
> is why, for example,
>
> x = 'buggy'[None]
>
> raises an exception instead of doing something stupid like returning 'g'.
You did read the sentence you were replying to, didn't you?
regards
Steve
--
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