[Python-Dev] string.find() again (was Re: timsort for jython)
Guido van Rossum
Mon, 05 Aug 2002 12:43:20 -0400
> Well, of course it can't be changed, but if Tim of all people made that
> mistake, I think it's a good indicator that something's wrong.
I'm not arguing with that, but I'm not sure how to fix it. We've
already got two substring test methods (index() and find()). Do we
really need a third?
> I believe
> the suggestion has been made to add an exists() method or something
> similar; it's probably better to have that in the core under some
> standard name instead of each person who needs it implementing the
> one-liner under different names.
Nobody writes the one-liner, everybody tries to remember to use
I don't like exists(). Maybe we should finally implement "s1 in s2"
as "s2.find(s1) >= 0", i.e. add a __contains__ method to strings?
--Guido van Rossum (home page: http://www.python.org/~guido/)