def booleanize(truthy):
if truthy is None:<EOL><INDENT>return False<EOL><DEDENT>elif isinstance(truthy, basestring):<EOL><INDENT>if truthy:<EOL><INDENT>try:<EOL><INDENT>return bool(distutils.util.strtobool(truthy))<EOL><DEDENT>except ValueError:<EOL><INDENT>return True<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>elif is_collection(truthy):<EOL><INDENT>return not is_empty(truthy)<EOL><DEDENT>else:<EOL><INDENT>return bool(truthy)<EOL><DEDENT>
Smartly converts argument to true or false. Strings and variants of
'true' and 'false' convert to appropriate types, along with normal
bool() like conversions.