title: Best way to split a hexadecimal?
body: <p>I'm pretty new to hexadecimal in general, and I've got an application that needs me to split a hexadecimal number. For example, given the number 0x607F, I would need to return the high (0x60) or low (0x7F) byte.</p>
  
  <p>This is may implementation, it feels a little cloogy though. Is there a more standard way to do this in python?</p>
  
  <pre><code>def byte(integer,highlow):
      assert highlow=='high' or highlow=='low'
      if highlow=='high':
          return hex(int(bin(integer)[:-8],2))
      if highlow=='low':
          return hex(int(bin(integer)[-8:],2))
  </code></pre>