Why comparison return an integer instead of a boolean?
<p>I was testing some piece of code</p>

<pre><code>True = 2
print 1 - (1 == 1)
print True == (1 == 1)
</code></pre>

<p>Then I was expecting:</p>

<pre><code>-1
True
</code></pre>

<p>But I got this instead:</p>

<pre><code>0
False
</code></pre>

<p>So, I did what any python programmer would do: disassemble it.</p>

<pre><code>def f():
    True = 2
    print 1 - (1 == 1)
    print True == (1 == 1)

2           0 LOAD_CONST               1 (2)
            3 STORE_FAST               0 (True)

3           6 LOAD_CONST               2 (1)
            9 LOAD_CONST               2 (1)
           12 LOAD_CONST               2 (1)
           15 COMPARE_OP               2 (==)
           18 BINARY_SUBTRACT     
           19 PRINT_ITEM          
           20 PRINT_NEWLINE       

4          21 LOAD_FAST                0 (True)
           24 LOAD_CONST               2 (1)
           27 LOAD_CONST               2 (1)
           30 COMPARE_OP               2 (==)
           33 COMPARE_OP               2 (==)
           36 PRINT_ITEM          
           37 PRINT_NEWLINE       
           38 LOAD_CONST               0 (None)
           41 RETURN_VALUE        
</code></pre>

<p>Then it was a bit clear, is using the <code>COMPARE_OP (==)</code>. Witch should return a boolean but it appears that it returns a integer instead. Any ideas why?</p>

<p><strong>Edit:</strong></p>

<p>In short the lesson learned: Changing the values of True or False doesn't change how the boolean logic is represented behind the scene.</p>
