Bug in string.find; was: Re: Proposed PEP: New style indexing, was Re: Bug in slice type
Sat Aug 27 06:08:05 CEST 2005
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'.
More information about the Python-list