<div dir="ltr">Thanks Danny!<br>That was an awesome explanation.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Apr 8, 2014 at 7:05 PM, Danny Yoo <span dir="ltr"><<a href="mailto:dyoo@hashcollision.org" target="_blank">dyoo@hashcollision.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><br>if line.strip()<br><br></div>Is that stripping the line of white space at the same time that it is testing it? <div class="gmail_extra">

<div><div>
<br></div></div></div></div></blockquote><div><br></div><div><br></div></div><div>Two features about Python:</div><div><br></div><div>1.  Strings are immutable, so the above is computing what a whitespace-stripped line would look like.  So that means that 'line.strip()' is doing just a computation: it's not mutating the original line, but computing a new string that has its leading and trailing whitespace stripped away.</div>


<div><br></div><div><br></div><div>2.  Empty strings are treated as false values.  I'm not happy with how loose Python treats truth, and would rather prefer:</div><div><br></div><div>    if line.strip() != "": ...</div>


<div><br></div><div>so that the thing being tested is explicitly either True or False.  I like my truth to be black and white, but I suppose I'll have to grimace and bear the fuzziness.  :P</div><div><br></div><div><br>


</div><div>Together, we see those two features allow us to look at the test in the Python code:</div><div><br></div><div>   if line.strip(): ...</div><div><br></div><div>and rephrase it in English as:</div><div><br></div>


<div>   "If the line consists of at least one non-whitespace character: ..."</div></div></div></div>
</blockquote></div><br><br clear="all"><br>-- <br><a href="http://jarednielsen.com" target="_blank">http://jarednielsen.com</a><br><a href="http://thehelloworldprogram.com" target="_blank">http://thehelloworldprogram.com</a><br>
<a href="http://dototot.com" target="_blank">http://dototot.com</a><br><br><br>
</div>