def try_number(value):
    """
    Attempt to cast the string `value` to an int, and failing that, a float,
    failing that, raise a ValueError.
    """

    for cast_function in [int, float]:
        try:
            return cast_function(value)
        except __HOLE__:
            pass

    raise ValueError("Unable to use value as int or float: {0!r}"
                     .format(value))
dataset/ETHPy150Open alphagov/performanceplatform-collector/performanceplatform/collector/ga/core.py/try_number