[Python-Dev] Remove str.find in 3.0?

Reinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Sat Aug 27 09:39:37 CEST 2005


Bill Janssen wrote:
>> There are basically two ways for a system, such as a 
>> Python function, to indicate 'I cannot give a normal response."  One (1a) 
>> is to give an inband signal that is like a normal response except that it 
>> is not (str.find returing -1).  A variation (1b) is to give an inband 
>> response that is more obviously not a real response (many None returns). 
>> The other (2) is to not respond (never return normally) but to give an 
>> out-of-band signal of some sort (str.index raising ValueError).
>> 
>> Python as distributed usually chooses 1b or 2.  I believe str.find and 
>> .rfind are unique in the choice of 1a.
> 
> Doubt it.  The problem with returning None is that it tests as False,
> but so does 0, which is a valid string index position.

Heh. You know what the Perl6 folks would suggest in this case?

return 0 but true; # literally!

> Might add a boolean "str.contains()" to cover this test case.

There's already __contains__.

Reinhold

-- 
Mail address is perfectly valid!



More information about the Python-Dev mailing list