'Cast value to int or float if necessary'

def check_numeric(self, value):

    if (not isinstance(value, (int, float))):
        try:
            value = int(value)
        except ValueError:
            value = float(value)
    return value
