Code review feedback.

This commit is contained in:
cahrens
2013-11-14 16:27:50 -05:00
parent 53a4016619
commit 569c86de74
7 changed files with 34 additions and 34 deletions

View File

@@ -2,14 +2,11 @@
Utilities for string manipulation.
"""
import ast
def str_to_bool(str):
"""
Converts "true" (case-insensitive) to the boolean True.
Everything else will return False.
Everything else will return False (including None).
An error will be thrown for non-string input (besides None).
"""
try:
return ast.literal_eval(str.title())
except:
return False
return False if str is None else str.lower() == "true"