def to_bool(x):
if isinstance(x, bool):<EOL><INDENT>return x<EOL><DEDENT>elif isinstance(x, str):<EOL><INDENT>return False if x.lower() in _FALSES else True<EOL><DEDENT>else:<EOL><INDENT>return bool(x)<EOL><DEDENT>
Converts to a boolean in a semantically meaningful way.