'Rename the key for a given value, without modifying sequence order.
For the case where new_key already exists this raise an exception,
since if new_key exists, it is ambiguous as to what happens to the
associated values, and the position of new_key in the sequence.
>>> od = OrderedDict()
>>> od[\'a\'] = 1
>>> od[\'b\'] = 2
>>> od.items()
[(\'a\', 1), (\'b\', 2)]
>>> od.rename(\'b\', \'c\')
>>> od.items()
[(\'a\', 1), (\'c\', 2)]
>>> od.rename(\'c\', \'a\')
Traceback (most recent call last):
ValueError: New key already exists: \'a\'
>>> od.rename(\'d\', \'b\')
Traceback (most recent call last):
KeyError: \'d\''

def rename(self, old_key, new_key):

    if (new_key == old_key):
        return
    if (new_key in self):
        raise ValueError(('New    key    already    exists:    %r' % new_key))
    value = self[old_key]
    old_idx = self._sequence.index(old_key)
    self._sequence[old_idx] = new_key
    dict.__delitem__(self, old_key)
    dict.__setitem__(self, new_key, value)
