I wrote this simple function:
def padded_hex(i, l): given_int = i given_len = l hex_result = hex(given_int)[2:] # remove \'0x\' from beginning o
How about this:
print '0x%04x' % 42