On 2005-08-26, Terry Reedy <[EMAIL PROTECTED]> wrote:
> Can str.find be listed in PEP 3000 (under builtins) for removal?
> Would anyone really object?
>

With all the discussion, I think you guys should realize that the
find/index method are actually convenient function which do 2 things in
one call:
1) If the key exists?
2) If the key exists, find it out.

But whether you use find or index, at the end, you *have to* break it into
2 step at then end in order to make bug free code. Without find, you can
do:

if s in txt:
   i = txt.index(s)
   ...
else:
   pass

or:
try:
   i = txt.index(s)
   ...
except ValueError:
   pass

With find:
i = txt.index(s)
if i >= 0:
  ...
else:
  pass

The code is about the same except with exception, the test of Exception
is pushed far apart instead of immediately. No much coding was saved.


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to