def hex_to_rgb(hexstring):
    """
    Converts a hexadecimal string to RGB tuple 
    
    Parameters
    ----------
    hexstring : str
        Hexadecimal string such as '#FFFFFF'
    Returns
    -------
    tuple
        RGB tuple such as (256,256,256)
    """
    #From http://stackoverflow.com/a/214657
    hexstring = hexstring.lstrip('#')
    lv = len(hexstring)
    return tuple(int(hexstring[i:i + lv // 3], 16) for i in range(0, lv, lv // 3))