@@ -24,7 +24,7 @@ def str_to_float_converter(use_none_on_fail=False):
24
24
Returns a human friendly float converter, can use use_none_on_fail to
25
25
return None if value cannot be converted.
26
26
"""
27
- def str_to_float (s ):
27
+ def str_to_float_func (s ):
28
28
"""
29
29
Convert a string to a float
30
30
"""
@@ -34,15 +34,15 @@ def str_to_float(s):
34
34
if use_none_on_fail :
35
35
return None
36
36
raise
37
- return str_to_float
37
+ return str_to_float_func
38
38
39
39
40
40
def str_to_int_converter (use_none_on_fail = False ):
41
41
"""
42
42
Returns a human friendly int converter, can use use_none_on_fail to return
43
43
None if value cannot be converted.
44
44
"""
45
- def str_to_int (s ):
45
+ def str_to_int_func (s ):
46
46
"""
47
47
Convert a string to a int
48
48
"""
@@ -55,7 +55,7 @@ def str_to_int(s):
55
55
if use_none_on_fail :
56
56
return None
57
57
raise
58
- return str_to_int
58
+ return str_to_int_func
59
59
60
60
61
61
def str_to_bool_converter (
@@ -90,7 +90,7 @@ def str_to_bool_converter(
90
90
"{} are both True and False" .format (boolean_true & boolean_false )
91
91
)
92
92
93
- def str_to_bool (s ):
93
+ def str_to_bool_func (s ):
94
94
"""
95
95
Convert a string to a bool, based on settings
96
96
"""
@@ -100,4 +100,11 @@ def str_to_bool(s):
100
100
if s in boolean_false :
101
101
return False
102
102
raise ValueError ("{} is neither True nor False." .format (s ))
103
- return str_to_bool
103
+ return str_to_bool_func
104
+
105
+
106
+ # versions using defaults so that users can import the actual functions, rather
107
+ # than creating their own
108
+ str_to_float = str_to_float_converter ()
109
+ str_to_int = str_to_int_converter ()
110
+ str_to_bool = str_to_bool_converter ()
0 commit comments