python 2.7 equivalent of built-in method int.from_bytes

You can treat it as an encoding (Python 2 specific):

>>> int('f483'.encode('hex'), 16)
1714698291

Or in Python 2 and Python 3:

>>> int(codecs.encode(b'f483', 'hex'), 16)
1714698291

The advantage is the string is not limited to a specific size assumption. The disadvantage is it is unsigned.

Leave a Comment