Alan, Thanks! Your response was helpful. I was trying to pass a number variable to the hex object. The output associated with this would be referenced in the hexoutput variable.
I guess this is as simple as.... hexoutput = "%X" % (value) Thanks again for the help, Tom On 5/25/05, Alan G <[EMAIL PROTECTED]> wrote: > > > Good evening! I am trying to pass a number variable and have it > > converted to hex. Any recommendations on how to achieve this? > > You appear to have answered your own question below. > What exactly is the problem? > > FAILS > ---------- > >>> value = 1234567890 > >>> hexoutput = hex('%d' % (value)) > > WORKS > ------------- > >>> hexoutput = hex(1234567890) > > Are you trying to insert a hex representation of the number into a > string for printing? If so the easiest way is using string format > characters: > > >>> print "In hex: %d = %X" % (42,42) > In hex: 42 = 2A > > HTH, > > Alan G > Author of the Learn to Program web tutor > http://www.freenetpages.co.uk/hp/alan.gauld > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor