Python Boolean comparison
<p>I'm testing Python's Boolean expressions. When I run the following code:</p>

<pre><code>x = 3
print type(x)
print (x is int)
print (x is not int)
</code></pre>

<p>I get the following results:</p>

<pre><code>&lt;type 'int'&gt;
False
True
</code></pre>

<p>Why is (x is int) returning false and (x is not int) returning true when clearly x is an integer type?</p>

<p>Try typing these into your interpreter: </p>

<pre><code>type(x)
int
x is 3
x is not 3
type(x) is int
type(x) is not int
</code></pre>

<p>The reason that <code>x is int</code> is false is that it is asking if the number <code>3</code> and the Python int class represent the same object. It should be fairly clear that this is false. </p>

<p>As a side note, Python's <code>is</code> keywords can work in some unexpected ways if you don't know exactly what it is doing, and you should almost certainly be avoiding it if you are ever testing equality. That being said, experimenting with it outside of your actual program is a very good idea.</p>

python boolean boolean-logic boolean-expression