String to Hex

Michael Foord fuzzyman at gmail.com
Wed Oct 27 06:42:51 EDT 2004


How do you safely turn an arbitrarily long signed hex string into a
long integer ?
e.g. -0x55aff8080000

When treating them as hex literals I'm getting future warnings that
from 2.4 hex values greater than sys.maxint will always return
positive values. I've had to treat them as strings and write a
function to turn them into longs a character at a time ! I couldn't
find a built in function that would do this for me.

Regards,

Fuzzy

http://www.voidspace.org.uk/atlantibots/pythonutils.html



More information about the Python-list mailing list