class documentation
class DuplicateSafeDict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): (source)
Dictionnary that do not discard old objects when they are overriden, but instead, only updates a reference to the new object.
Duplicate values can be fetched with methods getall
, getdup
and allitems
.
>>> d = DuplicateSafeDict(me='bob', you='claudia') >>> d['me'] = 'james' >>> d['me'] = 'james' >>> d['me'] = 'bob' >>> d.getall('me') ['james', 'bob'] >>> d['me'] = 'james' >>> d.getall('me') ['bob', 'james'] >>> d.getdup('me') ['bob'] >>> d == {'me':'bob', 'you':'claudia'} False >>> d == DuplicateSafeDict([('me', 'bob'), ('me', 'james'), ('you', 'claudia')]) True >>> del d['me'] >>> d.getall('me') ['bob'] >>> d == dict([('me', 'bob'), ('you', 'claudia')]) True
Method | __delitem__ |
Remove the last element added value for a key. |
Method | __eq__ |
Undocumented |
Method | __getitem__ |
Return the last element added that matches the name. |
Method | __init__ |
Undocumented |
Method | __iter__ |
Undocumented |
Method | __len__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | __setitem__ |
Undocumented |
Method | addvalue |
No summary |
Method | allitems |
Like 'items()' but returns all values, including duplicates. |
Method | copy |
Undocumented |
Method | getall |
Like 'get()' but returns all values for that name, including duplicates. |
Method | getdup |
Return the duplicates objects for that name. List might be empty. Raise key error if the name doesn't exist. |
Method | rmvalue |
Remove a value from the dict. The value can be a duplicate. If no values are left in the queue after the removal, the whole queue will be deleted. |
Instance Variable | _store |
Undocumented |