[Python-Dev] Dafanging the find() gotcha

Eric S Raymond esr@thyrsus.com
Mon, 5 Aug 2002 13:49:42 -0400


Tim Peters <tim.one@comcast.net>:
> [Eric S Raymond, breaking a too-long silence]

Thank you, Tim!

> > I think the right answer is to leave find() as it is and have a different
> > notation that returns bool.  How about `a in b' whenever a and b are
> > both string-valued?  Seems the most natural candidate.
> 
> I want to raise one other issue here:  should
> 
>     '' in 'xyz'
> 
> return True or raise an exception?

> IOW, do we follow find() rigidly, or retain "str1 in str2"'s current
> behavior when str1 is empty?

Raise an exception.  Definitely.  There is no reason to follow find() 
rigidly when the whole point is to have semantics different from find().  
Besides, you're right to point out that changing this behavior could 
break existing code, and that is a big no-no.
-- 
		<a href="http://www.tuxedo.org/~esr/">Eric S. Raymond</a>