title: Python if not == vs if !=
body: <p>What is the difference between these two lines of code:</p>
  
  <pre><code>if not x == 'val':
  </code></pre>
  
  <p>and </p>
  
  <pre><code>if x != 'val':
  </code></pre>
  
  <p>Is one more efficient than the other?</p>
  
  <p>Would it be better to use</p>
  
  <pre><code>if x == 'val':
      pass
  else:
  </code></pre>