2014-05-04 02:10:43 +02:00
|
|
|
def dict_raise_on_duplicates(ordered_pairs):
|
|
|
|
"""reject duplicate keys"""
|
|
|
|
my_dict = dict()
|
|
|
|
for key, values in ordered_pairs:
|
|
|
|
if key in my_dict:
|
2015-05-17 11:49:35 +02:00
|
|
|
raise ValueError("Duplicate key: {}".format(key,))
|
2014-05-04 02:10:43 +02:00
|
|
|
else:
|
2015-05-17 11:49:35 +02:00
|
|
|
my_dict[key] = values
|
|
|
|
return my_dict
|