<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jul 14, 2015 at 7:13 AM, Chris Angelico <span dir="ltr"><<a href="mailto:rosuav@gmail.com" target="_blank">rosuav@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Tue, Jul 14, 2015 at 2:58 PM, Steven D'Aprano<br>
<<a href="mailto:steve%2Bcomp.lang.python@pearwood.info">steve+comp.lang.python@pearwood.info</a>> wrote:<br>
> On Tuesday 14 July 2015 14:07, Ian Kelly wrote:<br>
><br>
>> On Mon, Jul 13, 2015 at 9:23 PM, Steven D'Aprano <<a href="mailto:steve@pearwood.info">steve@pearwood.info</a>><br>
>> wrote:<br>
</span><span class="">>>> Correct. But rather than removing it, it would be better to take a leaf<br>
>>> out of re.match's book and return None as the sentinel. That would<br>
>>> eliminate the "using -1 as a valid index" bug.<br>
>></span><span class=""><br>
>> Better IMO to just have the one non-redundant method that raises an<br>
>> exception rather than returning anything that could possibly be<br>
>> interpreted as a string index.<br>
><br>
><br>
> Well, maybe, but if you got rid of str.find, the first thing people would do<br>
> is recreate it:<br>
><br>
> def find(*args):<br>
>     try:<br>
>         return str.index(*args)<br>
>     except ValueError:<br>
>         return -1<br>
><br>
><br>
> Having a version of str.index that returns a sentinel is just too damn<br>
> handy.<br>
<br>
</span>Same as dictionaries have [] and .get(), although find doesn't allow<br>
you to change the sentinel.<br>
<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br></div><div>Maybe that is the solution?  Add a keyword-only argument to find to change the sentinel? <br></div></div><br></div></div>