def merge_dicts(dicts, deepcopy=False):
    """Merges dicts

    In case of key conflicts, the value kept will be from the latter
    dictionary in the list of dictionaries

    :param dicts: [dict, ...]
    :param deepcopy: deepcopy items within dicts
    """
    assert isinstance(dicts, list) and all(isinstance(d, dict) for d in dicts)
    return dict(chain(*[copy.deepcopy(d).items() if deepcopy else d.items()
                        for d in dicts]))
Merges dicts

    In case of key conflicts, the value kept will be from the latter
    dictionary in the list of dictionaries

    :param dicts: [dict, ...]
    :param deepcopy: deepcopy items within dicts