def hex2rgb(h):
    """ Convert a hex string or number to an RGB triple """
    # q.v. https://git.io/fh9E2
    if isinstance(h, str):
        return hex2rgb(int(h[1:] if h.startswith('#') else h, 16))
    return (h >> 16) & 0xff, (h >> 8) & 0xff, h & 0xff