title: Python: Difference between != and "is not"
body: <p>I'm unclear about the difference between the syntax <code>!=</code> and <code>is not</code>.  They appear to do the same thing:</p>
  
  <pre><code>&gt;&gt;&gt; s = 'a'
  &gt;&gt;&gt; s != 'a'
  False
  &gt;&gt;&gt; s is not 'a'
  False
  </code></pre>
  
  <p>But, when I use <code>is not</code> in a list comprehension, it produces a different result than if I use <code>!=</code>.</p>
  
  <pre><code>&gt;&gt;&gt; s = "hello"
  &gt;&gt;&gt; [c for c in s if c is not 'o']
  ['h', 'e', 'l', 'l', 'o']
  &gt;&gt;&gt; [c for c in s if c != 'o']
  ['h', 'e', 'l', 'l']
  </code></pre>
  
  <p>Why did the <code>o</code> get included in the first list, but not the second list?</p>