[Fwd: Re: hex string to hex value]

Brett g Porter bgporter at acm.org
Tue Nov 22 19:21:44 EST 2005


tim wrote:
> 
> 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)


As far as Python is concerned, 66 decimal and 42 hex are exactly the 
same thing. There's absolutely no difference in calling

note_off(0x42)
and

note_off(66)

See:

 >>> def f(c):
...    print c
...
 >>> f(66)
66
 >>> f(0x42)
66
 >>>



-- 
//  Today's Oblique Strategy (© Brian Eno/Peter Schmidt):
//  Repetition is a form of change
//  Brett g Porter * BgPorter at acm.org




More information about the Python-list mailing list