On Mon, Jul 13, 2015 at 10:56 AM, Roel Schroeven <r...@roelschroeven.net> wrote:
> Hi,
>
> Quick question: why does str have both index() and find(), while list only
> has index()? Is there a reason for that, or is it just an historical
> accident?

Historical accident, I think. If it were to be redone, I doubt that
str.find would exist. The problem with it is that it returns -1 to
indicate that the argument was not found, but -1 is a valid index into
the string. This is a potential source of hard-to-find bugs.

There was a long thread from 2005 on python-dev proposing to remove
str.find in Python 3, but evidently it didn't make the cut:
https://mail.python.org/pipermail/python-dev/2005-August/055704.html
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to