[Python-3000] find -> index patch

Hasan Diwan hasan.diwan at gmail.com
Thu Aug 24 00:09:35 CEST 2006


On 23/08/06, Josiah Carlson <jcarlson at uci.edu> wrote:
>
> ...that looks to have been done by a script, it has inconsistant style
> compared to the code it replaces, etc.
>

I made the minimal change that implements the functionality suggested, in
terms of find/rfind, they return -1. The least painful way to replace it
with index is:

try:
    i=str.index(foo)
except ValueError:
    i = -1

As for the plain except clauses, that was just laziness on my part. It's not
meant to be stylistically consistent or beautiful, rather it is meant to be
functional and as a starting point. Feel free to change/rewrite the patch.
The GENERAL CASE, i.e. one that is applicable throughout the code is the
try/except clauses shown above.
-- 
Cheers,
Hasan Diwan <hasan.diwan at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20060823/6e57fa69/attachment.html 


More information about the Python-3000 mailing list