title: Idiomatic way to port C bitfiddling to Python
body: <p>How would you port the following C code in a Pythonic way (especially the bit fiddling part in Get2, Get3, ...)</p>
  
  <pre><code>switch(mem[pos-1])
  {
    ...
    case 0x10: pos+=Get2(&amp;mem[pos+0x02])+0x04; break;
    case 0x11: pos+=Get3(&amp;mem[pos+0x0F])+0x12; break;
    case 0x16: pos+=Get4(&amp;mem[pos+0x00])+0x04; break;
    ...
    case 0x20: pos+=0x02; break;
  }
  
  ...
  
  //////////////////////////////////////////////////////////
  // Conversion routines to fetch bytes in Big Endian order
  //////////////////////////////////////////////////////////
  
  unsigned int Get2(unsigned char *pointer)
  {
    return (pointer[0] | (pointer[1]&lt;&lt;8));
  }
  
  unsigned int Get3(unsigned char *pointer)
  {
    return (pointer[0] | (pointer[1]&lt;&lt;8) | (pointer[2]&lt;&lt;16));
  }
  
  unsigned int Get4(unsigned char *pointer)
  {
    return (pointer[0] | (pointer[1]&lt;&lt;8) | (pointer[2]&lt;&lt;16) | (pointer[3]&lt;&lt;24));
  }
  </code></pre>
  
  <p>This is what I've got so far:</p>
  
  <pre><code>    x = struct.unpack('B', mem[pos-1])[0]
  
      if x == 0x10:
          # pos += ???
          continue
  
      if x == 0x11:
          # pos += ???
          continue
  
      if x == 0x16:
          # pos += ???
          continue
  
      if x == 0x20: 
          pos += 0x02
          continue
  </code></pre>