def hex2str(hexnum, intsize=4):
 if (not isinstance(hexnum, six.string_types)):
  nbits = (intsize * 8)
  hexnum = ('0x%x' % ((hexnum + (1 << nbits)) % (1 << nbits)))
 s = hexnum[2:]
 if ((len(s) % 2) != 0):
  s = ('0' + s)
 result = codecs.decode(s, 'hex')[::(-1)]
 return result

def hex2str ( hexnum , intsize = 4 ) : if ( not isinstance ( hexnum , six . string_types ) ) : nbits = ( intsize * 8 ) hexnum = ( '0x%x' % ( ( hexnum + ( 1 << nbits ) ) % ( 1 << nbits ) ) ) s = hexnum [ 2 : ] if ( ( len ( s ) % 2 ) != 0 ) : s = ( '0' + s ) result = codecs . decode ( s , 'hex' ) [ : : ( - 1 ) ] return result
convert a number in hex format to string .