def copy_dict(source_dict, diffs):
    """Returns a copy of source_dict, updated with the new key-value
       pairs in diffs."""
result = dict(source_dict)
result.update(diffs)
return result
How to copy a dict and modify it in one line of code