def _type_convert(val):
    """
    Attempt to convert a value into a numeric type.

    :param val: Value to attempt to convert
    :return: Converted value or unmodified value if conversion was not possible
    """
    for conv in (int, float):
        try:
            return conv(val)

        except ValueError:
            pass

    return val