def compilable(text, mode='exec'):
    """Return True if a string can be compiled"""
    if not mode in ['eval', 'exec']:
        raise ValueError(f'"{mode}" is an invalid compile mode')
    try:
        compile(text, '', mode)
        return True
    except:
        pass
    return False
