If you want to accept more than just ints, you should use float:
def is_numeric(s):
try:
float(s)
return True
except ValueError:
return False
duration = inputScriptLine.split(' ', 1)[1]
if not is_numeric(duration):
print(' Error: Sleep duration {} is not numeric'.format())
float("1.0"), float("1"), float("1.5")Etc. all will return True, but int ("1.0"), int("1.5")etc. will also return False, if you are really looking for numerical input, it will be wrong.
, , f > 0:
def is_positive_numeric(s):
try:
f = float(s)
return f > 0
except ValueError:
return False