Class UnorderedMultiDict
source code
_BaseMultiDict --+
|
UnorderedMultiDict
Store key/value mappings.
Acts like a standard dictionary with the following features:
-
duplicate keys are allowed;
-
input order is preserved for all values of a given key but not
between different keys.
>>> ud = UnorderedMultiDict([("Food", "Spam"), ("Color", "Blue"),
... ("Food", "Eggs"), ("Color", "Green")])
>>> ud["Food"]
'Eggs'
>>> ud.getall("Food")
['Spam', 'Eggs']
>>>
The order of values from a given key (as from
ud.getall("Food")) is guaranteed but the order between keys (as
from od.allkeys() and od.allitems()) is not.
Can also pass in an object to the constructor which has an allitems()
method that returns a list of key/value pairs.
|
|
|
__eq__(self,
other)
Does this UnorderedMultiDict have the same keys, with values in the
same order, as another? |
source code
|
|
|
__ne__(self,
other)
Does this UnorderedMultiDict NOT have the same keys, with values in
the same order, as another? |
source code
|
|
|
|
|
|
|
__delitem__(self,
key)
Remove all values for the given key |
source code
|
|
|
allkeys(self)
iterate over all keys in arbitrary order |
source code
|
|
|
allvalues(self)
iterate over all values in arbitrary order |
source code
|
|
|
|
Inherited from _BaseMultiDict :
__contains__ ,
__getitem__ ,
__iter__ ,
__len__ ,
__str__ ,
get ,
getall ,
items ,
keys ,
values
|
__setitem__(self,
key,
value)
(Index assignment operator)
| source code
|
Add a new key/value pair
If the key already exists, replaces the existing value so that d[key]
is the new value and not the old one.
To get all values for a given key, use d.getall(key).
|
iterate over all key/value pairs, in arbitrary order
Actually, the keys are iterated in arbitrary order but all values for
that key are iterated at sequence of addition to the
UnorderedMultiDict.
|