I found dictionary unpacking to be quite useful, when you don't want to mutate things. Code like:
new_dict = {**old_dict, **update_keys_and_values_dict}
Or even complexer: new_dict = {
**old_dict,
**{
key: val
for key, val in update_keys_and_values_dict
if key not in some_other_dict
}
}
It is quite flexible. replies(1):