def get_str_from_rgb255(inp):
    """Converts RGB tuples of ints from between 0 and 255 to RGB hex strings of type `#RRGGBB`

    Parameters
    ----------
    input : tuple
        Tuple of r, g, b values in range from 0 to 255


    Returns
    -------
    str
        RGB hex string of form '#NNNNNN'

    Raises
    ------
    ValueError if values are out of range
    """
    err_msg = "Cannot convert malformed tuple to string. Should be (0..255, 0..255, 0..255). Is: (%s)" % ", ".join(
        [str(X) for X in inp]
    )
    try:
        assert len(inp) == 3
        for x in inp:
            assert x >= 0 and x <= 255
        stmp = "#{:0>2X}{:0>2X}{:0>2X}".format(*inp)
        assert len(stmp) == 7
        return stmp
    except IndexError:
        raise ValueError(err_msg)
    except AssertionError:
        raise ValueError(err_msg)
    except TypeError:
        raise ValueError(err_msg)