0

(in case you're curious about motivation: this will be used in a scons build to generate a C file containing a GUID)

I found the question about generating a GUID in python. But I don't really know much about programming python. Could someone help me convert this to a string of the form

"{0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**}"

where the **'s are filled in with the GUID bytes in 2-digit hex form?

def getInitializer(someUUID):
    hexByteList = [??? for b in someUUID.bytes]
    return '{'+(', '.join(hexByteList))+'}'

I'm not sure what to use for the "???" above.

Community
  • 1
  • 1
Jason S
  • 184,598
  • 164
  • 608
  • 970

1 Answers1

2
hex(ord(b))

...

Jason Orendorff
  • 42,793
  • 6
  • 62
  • 96