[Fwd: Re: hex string to hex value]
Rocco Moretti
roccomoretti at hotpop.com
Tue Nov 22 19:10:20 EST 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
66
>>> note is 66
True
There is no such thing as a "hex value"- only hex *representations* of a
value.
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