<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3157" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=377260215-31102007><FONT face=Arial
color=#0000ff size=2>I believe most programming languages evaluate 0 to mean
False, and anything else to be True (for the purposes of boolean
evaluation). Python is no exception.</FONT></SPAN></DIV><BR>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B>
python-list-bounces+james.b.looney=lmco.com@python.org
[mailto:python-list-bounces+james.b.looney=lmco.com@python.org] <B>On Behalf
Of </B>jelle feringa<BR><B>Sent:</B> Wednesday, October 31, 2007 8:56
AM<BR><B>To:</B> Luis Zarrabeitia<BR><B>Cc:</B>
python-list@python.org<BR><B>Subject:</B> Re: shouldn't 'string'.find('ugh')
return 0, not -1 ?<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV>There is a subtle point though.</DIV>
<DIV>If the substring is not found '_'.find(' '), will return -1</DIV>
<DIV>Semanticly, I was expecting the that if the substring was not found, the
conditional statement would not be found.</DIV>
<DIV>However, python evaluates -1 to True, so that is what I do find
confusing.</DIV>
<DIV>So, I was arguing that '_'.find(' ') might return 0, however that is
obviously ambigious, since 0 might be an index as well.</DIV>
<DIV> </DIV>
<DIV>So, perhaps I should rephrase and ask, why if -1 evaluates to True?</DIV>
<DIV>I think that's pretty ugly...</DIV>
<DIV> </DIV>
<DIV>cheers,</DIV>
<DIV> </DIV>
<DIV>-jelle</DIV></BLOCKQUOTE></BODY></HTML>