dict.__setitem__(self, val, key)

def __delitem__(self, key):
    dict.__delitem__(self, self[key])
dict.__delitem__(self, key)
d = BidirectionalDict()
d['foo'] = 4
print(d[4])
Обратимый словарь для python