title: Python - comparing long/integer values with == and is
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/306313/python-is-operator-behaves-unexpectedly-with-integers">Python &ldquo;is&rdquo; operator behaves unexpectedly with integers</a>  </p>
  </blockquote>
  
  
  
  <p>Ran into something odd last night where doing</p>
  
  <pre><code>if max_urls is 0:
      max_urls = 10
  </code></pre>
  
  <p>would always return false... even when max_urls was 0.... it was getting assigned from the database. When I did a</p>
  
  <pre><code>print type(max_urls)
  </code></pre>
  
  <p>would return</p>
  
  <pre><code>&lt;type 'long'&gt; 0
  </code></pre>
  
  <p>which seemed right but it would always return false.</p>
  
  <p>If I changed it to</p>
  
  <pre><code>if max_urls == 0:
      max_urls = 10
  </code></pre>
  
  <p>then finally it would return true when it was 0. Why the difference between == and is?</p>