def update_matching(dct, key_pattern, new_dct): for key in dct: if fnmatch.fnmatchcase(key, key_pattern): new_dct[key] = dct[key]