title: String comparison in Python: is vs. ==
body: <p>I noticed a Python script I was writing was acting squirrelly, and traced it to an infinite loop, where the loop condition was <code>while line is not ''</code>. Running through it in the debugger, it turned out that line was in fact <code>''</code>. When I changed it to <code>!=''</code> rather than <code>is not ''</code>, it worked fine. </p>
  
  <p>Also, is it generally considered better to just use '==' by default, even when comparing int or Boolean values? I've always liked to use 'is' because I find it more aesthetically pleasing and pythonic (which is how I fell into this trap...), but I wonder if it's intended to just be reserved for when you care about finding two objects with the same id.</p>