I have a string that can be a hex number prefixed with "0x" or a decimal number without a special prefix except for possibly a minus sign. "0x123" is in base 16 and "-298" is in base 10.
How do I convert this to an int or long in Python?
I don't want to use eval() since it's unsafe and overkill.