Re: Converting hex to char help

2006-05-14 Thread Tim Chase
> How can I convert a string "0x62" to int/hex without this problem? The call to int() takes an optional parameter for the base: >>> print int.__doc__ int(x[, base]) -> integer Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (thi

Re: Converting hex to char help

2006-05-14 Thread Sybren Stuvel
Ognjen Bezanov enlightened us with: > Hi all, I am trying to convert a hexdecimal value to a char using this code: > > print ' %c ' % int(0x62) This is an integer > this works fine, but if I want to do this: > > number = "62" > print ' %c ' % int("0x" + number) This is a string ^^^

Converting hex to char help

2006-05-14 Thread Ognjen Bezanov
Hi all, I am trying to convert a hexdecimal value to a char using this code: print ' %c ' % int(0x62) this works fine, but if I want to do this: number = "62" print ' %c ' % int("0x" + number) I get an error: Traceback (most recent call last): File "",line 1, in ? ValueError: invalid literal