Thanks!  I just realised that too, but I used the condition:    .find() > 0 <div>But I think your's is better.<br><div>Simple programming knowledge...  > <<div><div><br></div><div>I made a blog post:</div><div>

<a href="http://learnwithhelvin.blogspot.com/2009/09/1-is-true-if-loops.html">http://learnwithhelvin.blogspot.com/2009/09/1-is-true-if-loops.html</a></div><div><br></div><div><a href="http://learnwithhelvin.blogspot.com/2009/09/1-is-true-if-loops.html"></a><br>

<br><div class="gmail_quote">On Thu, Sep 3, 2009 at 5:19 PM, Stephen Hansen <span dir="ltr"><<a href="mailto:apt.shansen@gmail.com">apt.shansen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The amazing thing is when file_str  = 'C:\Qt\SimLCM\Default<br>
\Data_Input_Material.txt',<br>
the first if statement if fulfilled, that seemingly says that in this<br>
file_str, python actually finds the word 'Geometry'.<br>
I know this, because the line: 'I found geometry' is printed. However,<br>
if instead of using file_str.find(), I use file_str.endswith(), it<br>
does not exhibit this strange behaviour.<br>
<br></blockquote><div><br></div><div>The problem is str.find returns -1 on failure; and -1 is a true value. Only 0, empty string, empty sequences, etc, are false values.</div><div><br></div><div>So, you have to test, 'if find_str.find(pattern) != -1:'</div>



<div><br></div><div>HTH,</div><div><br></div><font color="#888888"><div>--S</div></font></div>
</blockquote></div><br><br clear="all"><br>-- <br>Helvin <br><br>"Though the world may promise me more, I'm just made to be filled with the Lord."<br>
</div></div></div></div>