how to parse hex or decimal int in Python
<p>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.</p>

<p>How do I convert this to an int or long in Python?</p>

<p>I don't want to use eval() since it's unsafe and overkill.</p>
