def dict_raise_on_duplicates(ordered_pairs):
    """Reject duplicate keys. Python does not do this by default."""
    dictionary = {}
    for key, value in ordered_pairs:
        if key in dictionary:
           raise ValueError("Duplicate key: %r" % (key,))
        else:
           dictionary[key] = value
    return dictionary