[Python-Dev] Let's stop eating exceptions in dict lookup
Fredrik Lundh
fredrik at pythonware.com
Tue May 30 07:46:46 CEST 2006
Guido van Rossum wrote:
>>> well, the empty string is a valid substring of all possible strings
>>> (there are no "null" strings in Python). you get the same behaviour
>>> from slicing, the "in" operator, "replace" (this was discussed on the
>>> list last week), "count", etc.
>
>> Although Tim pointed out that replace() only regards
>> n+1 empty strings as existing in a string of lenth
>> n. So for consistency, find() should only find them
>> in those places, too.
depends on how you interpret the reference to "slices" in the docs.
"abc"[100:] is an empty string, and so is "abc"[100:100].
> And "abc".count("") should return 4.
it does, and has always done (afaik). "abc".count("", 100) did use to
return -96, though, which is hard to explain in terms of anything else.
</F>
More information about the Python-Dev
mailing list