title: Python invert a number
body: <p>First of all I'm not a Python expert, so here is my topic:</p>
  
  <p>I want to invert a number, let say <code>number = "ABCD123"</code> (yes this is a string but I need to do it this way ...), the problem is that I'm not really satisfy with the way Python deal with the inversion, for example <code>~0xABCD123</code> is <code>-180146468</code> and I don't want the MSB but only the "current" bits to be inverted. I can go with something like <code>~0xABCD123 &amp; 0XFFFFFFF</code> but the size of the number can actually change...</p>
  
  <p><strong>Question</strong></p>
  
  <p>Is there a way to dynamically "cast" or remove the bit sign in Python with the operator <code>~</code></p>