views:

24

answers:

1

Hi,

I need to convert an ARGB hex into an int in Jython for color. I've tried using longs, hex() and a combination of other things and can't seem to get it to work.

I get this error "TypeError : 5th arg can't be coerced to int" when I try to convert 0x80ff3333 to an int.

I guess there are too many bytes in the hex to convert it. Anyone know the syntax for this conversion?

Thanks!

+2  A: 

Just pass a second argument for the base to the int-function.

Jython 2.5.2b1 (trunk:7081M, Jul 20 2010, 18:56:05) 
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_20
Type "help", "copyright", "credits" or "license" for more information.
>>> int('0x80ff3333',16)
2164208435L
>>> # verification
>>> hex(_)
'0x80ff3333L'
thobe