Dev Helpers
← Back

Detect conflicting values before merging maps

Detect conflicting values before merging maps using Python lists and dictionaries.

Open this example in the interactive library

Source code

left = {'host': 'east', 'port': 80}
right = {'port': 443, 'tls': True}
conflicts = {k: (left[k], right[k]) for k in sorted(left.keys() & right.keys()) if left[k] != right[k]}
print(conflicts)

Sample output

{'port': (80, 443)}