If a Python string variable has had either an integer, floating point number or a non-numeric string placed in it, is there a way to easily test the \"type\" of that value?<
import ast def type_of_value(var): try: return type(ast.literal_eval(var)) except Exception: return str
Or, if you only want to check for int, change the third line to block inside try with:
try
int(var) return int