jrlen balane <[EMAIL PROTECTED]> writes:
> ex. hexa = '0x87BE" # what i want to do is:
> a = 0x87, b = 0xBE # so that i could do this:
> c = a + b #which should be equal to 0x145
Assuming you really want hexa to begin with the characters '0x', the
string slicing way is:
a, b = hexa[2:4], hexa[4:6] # a = '87', b = 'BE'
c = int(a,16) + int(b, 16)
A more direct arithmetic way is:
x = int(hexa, 16) # x = the integer 0x87be
c = (x >> 8) + (x & 0xff)
--
http://mail.python.org/mailman/listinfo/python-list