我们从Python开源项目中,提取了以下18个代码示例,用于说明如何使用UserDict.UserDict.__setitem__()。
def __setitem__(self, key, value): """Associate 'value' with 'key'. If 'key' already exists, but in different case, it will be replaced.""" k = self._lowerOrReturn(key) self.data[k] = (key, value)
def __setitem__(self, key, value): if not self.has_key(key): self._order.append(key) UserDict.__setitem__(self, key, value)
def __setitem__(self, key, value): for k in self.keymap.keys(): if key == k: key = self.keymap[k] if type(key) == types.ListType: key = key[0] return UserDict.__setitem__(self, key, value)
def __setattr__(self, key, value): if key.startswith('_') or key == 'data': self.__dict__[key] = value else: return self.__setitem__(key, value)
def __setitem__(self, key, item): UserDict.__setitem__(self, key, item) if key not in self._keys: self._keys.append(key)
def update(self, dict): for (key, val) in dict.items(): self.__setitem__(key, val)
def __setitem__(self, i, item): UserList.__setitem__(self, i, item) self.unique = False
def __setitem__(self, i, v): return self
def __setitem__(self, key, value): data = base64.b64encode(pickle.dumps(value)).decode('ascii') return UserDict.__setitem__(self, key, data)
def __setitem__(self, key, value): if self.get(key) != value: if key in self: self.del_value(self[key]) if value in self._reversed: del self[self.get_key(value)] self._reversed[value] = key if PY2: return UserDict.__setitem__(self, key, value) else: return super(TwoWayDict, self).__setitem__(key, value)