[Fwd: Re: hex string to hex value]

Rocco Moretti roccomoretti at hotpop.com
Wed Nov 23 01:10:20 CET 2005

tim wrote:
> ok, but if i do
>  >>> n=66
>  >>> m=hex(n)
>  >>> m
> '0x42'
>  >>> h=int(m,16)
>  >>> h
> 66
>  >>>
> I end up with 66 again, back where I started, a decimal, right?
> I want to end up with 0x42 as being a hex value, not a string, so i can 
> pas it as an argument to a function that needs a hex value.
> (i am trying to replace the 0x42 in the line  midi.note_off(channel=0, 
> note=0x42) with a variable)

 >>> note = 0x42
 >>> print note
 >>> note is 66

There is no such thing as a "hex value"- only hex *representations* of a 

midi.note_off() doesn't take a "hex value", it takes an integer, and, 
for whatever reason, it happens to be listed in your example in a 
hexidecimal representation.

More information about the Python-list mailing list