common_dict#

common_dict(*dicts)#

Return a dictionary containing key-value pairs that are common across all input dictionaries.

A key-value pair is included in the result if: - The key exists in every dictionary. - All dictionaries have the same value associated with that key.

Parameters:

*dicts: Any number of dictionaries to compare.

Returns:
dict: A dictionary of key-value pairs shared by all input dictionaries with equal values.

Returns an empty dictionary if no common key-value pairs exist or if no dictionaries are given.

Example:
>>> common_dict({'a': 1, 'b': 2}, {'a': 1, 'b': 3}, {'a': 1})
{'a': 1}