title: How do you express binary literals in Python?
body: <p>How do you express an integer as a binary number with Python literals?</p>
  
  <p>I was easily able to find the answer for hex:</p>
  
  <pre><code>&gt;&gt;&gt; 0x12AF
  4783
  &gt;&gt;&gt; 0x100
  256
  </code></pre>
  
  <p>and octal:</p>
  
  <pre><code>&gt;&gt;&gt; 01267
  695
  &gt;&gt;&gt; 0100
  64
  </code></pre>
  
  <p><strong>How do you use literals to express binary in Python?</strong></p>
  
  <hr>
  
  <p><strong><em>Summary of Answers</em></strong></p>
  
  <ul>
  <li>Python 2.5 and earlier: can express binary using <code>int('01010101111',2)</code> but not with a literal.</li>
  <li>Python 2.5 and earlier: there is <em>no way</em> to express binary literals.</li>
  <li>Python 2.6 beta: You can do like so: <code>0b1100111</code> or <code>0B1100111</code>.</li>
  <li>Python 2.6 beta: will also allow <code>0o27</code> or <code>0O27</code> (second character is the letter O) to represent an octal.</li>
  <li>Python 3.0 beta: Same as 2.6, but will no longer allow the older <code>027</code> syntax for octals.</li>
  </ul>