title: Is it guaranteed that False "is 0" and True "is 1"?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2764017/is-false-0-and-true-1-in-python-an-implementation-detail-or-is-it-guarante">Is False == 0 and True == 1 in Python an implementation detail or is it guaranteed by the language?</a>  </p>
  </blockquote>
  
  
  
  <p>I noticed today that the following works using python 2.6 (Cpython)...</p>
  
  <pre><code>&gt;&gt;&gt; a=[100,200]
  &gt;&gt;&gt; a[True]
  200
  &gt;&gt;&gt; a[False]
  100
  </code></pre>
  
  <p>Is this portable to other python implementations (e.g. is <code>True</code>/<code>False</code> guaranteed to inherit from int?  Is <code>True</code> guaranteed to evaluate to 1 instead of some other non-zero number?)  Is there any situation where this would be useful?  It seems like it could be used as another form of a ternary operator, but I don't know how much is gained there...</p>