def __number_or_string(val):
    """
    convert a string to a number if the string represents a number;
    otherwise, return the string.
    """
    try:
        val = float(val.strip())
    except ValueError:
        pass
    return val