def FormatAsHexString(num, width=None, prefix='0x'):
 hex_str = hex(num)[2:]
 hex_str = hex_str.replace('L', '')
 if width:
  hex_str = hex_str.rjust(width, '0')
 return ('%s%s' % (prefix, hex_str))

def FormatAsHexString ( num , width = None , prefix = '0x' ) : hex_str = hex ( num ) [ 2 : ] hex_str = hex_str . replace ( 'L' , '' ) if width : hex_str = hex_str . rjust ( width , '0' ) return ( '%s%s' % ( prefix , hex_str ) )
takes an int and returns the number formatted as a hex string .