Refactor can_only_be_decimal to use can_also_be_decimal
1 files changed, 5 insertions(+), 13 deletions(-)

M showcolours.py
M showcolours.py +5 -13
@@ 153,21 153,13 @@ def parse_args(args):
 
 
 def can_only_be_decimal(number):
-    """Could the number string only represent a decimal in the range 0-1?
+    """Can the number string only represent a decimal in the range 0-1, and
+    not an integer in the range 0-255?
 
-    It has to contain a dot, too. That way we can make the distinction:
-    The triplet (1., 0, 0) is decimal red, whereas (1, 0, 0) is in the 0-255
-    range and as good as black.
+    We say yes if (a) it can represent a decimal in the range 0-1, and (b) it
+    contains a dot, which we take to mean it isn't an int.
     """
-    if type(number) is not str:
-        raise TypeError
-    try:
-        if 0 <= float(number) <= 1 and '.' in number:
-            return True
-        else:
-            return False
-    except ValueError:
-        return False
+    return can_also_be_decimal(number) and '.' in number
 
 
 def can_also_be_decimal(number):