I am trying to write a method for converting hexadecimal words to signed integers. I want to use python 2-7. In python3 I can do the following
def word2int(hex_str):
ba = bytes.fromhex(hex_str)
return int.from_bytes(ba,byteorder='big',signed=True)
However, neither of these methods (i.e. fromhex and from_bytes) are defined in python 2-7. Are there any nice and simple methods of doing this in Python 2-7?
structmodule? docs.python.org/2/library/struct.html