<div><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"> The statement that you want to test the truth of is s.find(q) >= 0.  In other words, you want to see that the substring was found at a valid (non-negative) location. As someone else pointed out, it would make more sense to use None instead of -1.
</blockquote>
<div> </div>
<div>I agree, that would be nice.</div><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">  You still couldn't use `if s.find(q):` because you'd get a false result for a substring found at the beginning of the string, but the return value would make more intuitive sense.
</blockquote>
<div> </div>
<div>I'm sorry, but is that so?</div>
<div>>>>None == 0<br>False</div>
<div> </div>
<div>Since the start of the string is indicated by 0 and not None, that should work, right?</div><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Witness also the problem of actually using the result of find:<br><br>s[s.find(q)]<br><br>will yield a valid part of the string (the last character) when q is not found.  If it evaluated to none, you'd get a respectable TypeError instead.
<br><br>But you still wouldn't--and never will--be able to say `if s.find(q)`, because valid array indices can be either true or false.</blockquote>
<div> </div>
<div>Yes, but that is the issue here. If the substring is not found, still find() returns -1, which is a valid indice.</div>
<div>That I think is ugly. I can't think of a case where it would be prefereble to have find() return -1 rather than None.</div>
<div>Formally speaking, -1 is an ambigious answer, since a perfectly valid indice.</div>
<div> </div>
<div>the '_'.find(' ') might actually make a nice idiom while parsing for ignoring irrelevant lines, and processing lines that are of interest in the conditional expression.</div>
<div> </div>
<div>Cheers,</div>
<div> </div>
<div>-jelle</div></div><br>