def parse_list_result(match_list, raw_list):
    """Checks that a list of values matches the form specified in a format list.

    Entries in the match_list can either be tuples or single values.  If a
    single value, e.g. a string or integer, then the corresponding entry in the
    raw_list must match exactly.  For tuple items, the corresponding raw_list
    entry is converted and added to the results dictionary that is returned.

    Tuple entries consist of two elements: the key name to be used in the result
    and the function to call to convert the raw_list item.

    Example:
    parse_list_result(
        ['first:', ('1st', int), 'second:', ('2nd', float)],
        ['first:', '555', 'second:', '1.23']
        )
    would return {'1st': 555, '2nd': 1.23}.
    If elements 0 and 2 were not 'first:' and 'second:' respectively then an
    exception is thrown.  Exceptions thrown by the conversion functions are not
    caught.
    """
    if len(match_list) != len(raw_list):
        raise Exception('len("{}") != len("{}") ({}, {})'.format(match_list, raw_list, len(match_list), len(raw_list)))

    res = {}
    for idx, match in enumerate(match_list):
        data = raw_list[idx]
        if isinstance(match, tuple):
             key, conv_fn = match
             res[key] = conv_fn(data)
        else:
            if match != data:
                raise Exception('"{}" != "{}" ({})'.format(match, data, idx))

    return res