[Tutor] built-in hex->int question

Huuuuuu mennosimons@gmx.net
Tue, 8 Jan 2002 00:21:30 +0100


Hi Tutor,

Why understands the float() function a string argument but not 
integer-cast-functions?

>>> int('0xaf')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ValueError: invalid literal for int(): 0xaf
>>> long('0xaf')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ValueError: invalid literal for long(): 0xaf
>>> float('0xaf')
175.0

Thanks,
willi