def rgb2hex(rgb):
    """
    Convert RGB(A) tuple to hex.
    """
    if len(rgb) > 3:
        rgb = rgb[:-1]
    return "#{0:02x}{1:02x}{2:02x}".format(*(int(v*255) for v in rgb))
def rgb2hex ( rgb ) : if len ( rgb ) > 3 : rgb = rgb [ : - 1 ] return "#{0:02x}{1:02x}{2:02x}" . format ( * ( int ( v * 255 ) for v in rgb ) )
Convert RGB(A) tuple to hex.