class UniqueDict(dict):

    def __setitem__(self, key, value):
        if key not in self:
            dict.__setitem__(self, key, value)
How can I force a dictionary in python to only have unique keys?