[Python-Dev] string.find() again (was Re: timsort for jython)
Neal Norwitz
neal@metaslash.com
Mon, 05 Aug 2002 15:12:03 -0400
Guido van Rossum wrote:
>
> I wrote:
> > I personally see no way to defend ('' in 'x') returning false; it's so
> > clearly a substring that any definition of substring-ness that
> > excludes this seems mathematically wrong, despite your good
> > intentions.
>
> However, the backwards compatibility argument makes sense. It used to
> raise an exception and it would probably break code if it stopped
> doing so; longer strings are much less likely to be passed by accident
> so the need for the exception there is less strong. I'm of two minds
> on this now...
Here's a patch: http://python.org/sf/591250
In testing this patch, I ran across this:
>>> 's' in 's'
True
>>> 's' in 's' == True
False
>>> 's' in 's' is True
False
>>> id('s' in 's')
135246792
>>> id(True)
135246792
What's up with that? Am I missing something?
Note: this occurs before the patch too.
Neal