dict.__setitem__(self, 'a', 'b')

def __setitem__(self, key, value):
    if key in self:
        dict.__setitem__(self, key, value)
a = a()
print(a['a'])
a['c'] = 'd'
a['a'] = 'e'
print(a['a'])
вставка в словарь python