def str2bool(string): str2val = {"True": True, "False": False} if string in str2val: return str2val[string] else: raise ValueError( f"Expected one of {set(str2val.keys())}, got {string}")