OpenQuizz
Une application de gestion des contenus pédagogiques
|
Public Member Functions | |
def | __init__ (self, mapping=None) |
def | __eq__ (self, other) |
def | __ne__ (self, other) |
def | __reduce_ex__ (self, protocol) |
def | __getstate__ (self) |
def | __setstate__ (self, values) |
def | __getitem__ (self, key) |
def | __setitem__ (self, key, value) |
def | __delitem__ (self, key) |
def | keys (self) |
def | values (self) |
def | items (self, multi=False) |
def | lists (self) |
def | listvalues (self) |
def | add (self, key, value) |
def | getlist (self, key, type=None) |
def | setlist (self, key, new_list) |
def | setlistdefault (self, key, default_list=None) |
def | update (self, mapping) |
def | poplist (self, key) |
def | pop (self, key, default=_missing) |
def | popitem (self) |
def | popitemlist (self) |
![]() | |
def | setdefault (self, key, default=None) |
def | copy (self) |
def | deepcopy (self, memo=None) |
def | to_dict (self, flat=True) |
def | __copy__ (self) |
def | __deepcopy__ (self, memo) |
def | __repr__ (self) |
![]() | |
def | get (self, key, default=None, type=None) |
Works like a regular :class:`MultiDict` but preserves the order of the fields. To convert the ordered multi dict into a list you can use the :meth:`items` method and pass it ``multi=True``. In general an :class:`OrderedMultiDict` is an order of magnitude slower than a :class:`MultiDict`. .. admonition:: note Due to a limitation in Python you cannot convert an ordered multi dict into a regular dict by using ``dict(multidict)``. Instead you have to use the :meth:`to_dict` method, otherwise the internal bucket objects are exposed.
def __init__ | ( | self, | |
mapping = None |
|||
) |
Reimplemented from MultiDict.
def __delitem__ | ( | self, | |
key | |||
) |
def __eq__ | ( | self, | |
other | |||
) |
def __getitem__ | ( | self, | |
key | |||
) |
Return the first data value for this key; raises KeyError if not found. :param key: The key to be looked up. :raise KeyError: if the key does not exist.
Reimplemented from MultiDict.
def __getstate__ | ( | self | ) |
Reimplemented from MultiDict.
def __ne__ | ( | self, | |
other | |||
) |
def __reduce_ex__ | ( | self, | |
protocol | |||
) |
def __setitem__ | ( | self, | |
key, | |||
value | |||
) |
Like :meth:`add` but removes an existing key first. :param key: the key for the value. :param value: the value to set.
Reimplemented from MultiDict.
def __setstate__ | ( | self, | |
values | |||
) |
Reimplemented from MultiDict.
def add | ( | self, | |
key, | |||
value | |||
) |
Adds a new value for the key. .. versionadded:: 0.6 :param key: the key for the value. :param value: the value to add.
Reimplemented from MultiDict.
def getlist | ( | self, | |
key, | |||
type = None |
|||
) |
Return the list of items for a given key. If that key is not in the `MultiDict`, the return value will be an empty list. Just as `get` `getlist` accepts a `type` parameter. All items will be converted with the callable defined there. :param key: The key to be looked up. :param type: A callable that is used to cast the value in the :class:`MultiDict`. If a :exc:`ValueError` is raised by this callable the value will be removed from the list. :return: a :class:`list` of all the values for the key.
Reimplemented from MultiDict.
def items | ( | self, | |
multi = False |
|||
) |
Return an iterator of ``(key, value)`` pairs. :param multi: If set to `True` the iterator returned will have a pair for each value of each key. Otherwise it will only contain pairs for the first value of each key.
Reimplemented from MultiDict.
def keys | ( | self | ) |
Reimplemented from MultiDict.
def lists | ( | self | ) |
Return a iterator of ``(key, values)`` pairs, where values is the list of all values associated with the key.
Reimplemented from MultiDict.
def listvalues | ( | self | ) |
Return an iterator of all values associated with a key. Zipping :meth:`keys` and this is the same as calling :meth:`lists`: >>> d = MultiDict({"foo": [1, 2, 3]}) >>> zip(d.keys(), d.listvalues()) == d.lists() True
Reimplemented from MultiDict.
def pop | ( | self, | |
key, | |||
default = _missing |
|||
) |
Pop the first item for a list on the dict. Afterwards the key is removed from the dict, so additional values are discarded: >>> d = MultiDict({"foo": [1, 2, 3]}) >>> d.pop("foo") 1 >>> "foo" in d False :param key: the key to pop. :param default: if provided the value to return if the key was not in the dictionary.
Reimplemented from MultiDict.
def popitem | ( | self | ) |
Pop an item from the dict.
Reimplemented from MultiDict.
def popitemlist | ( | self | ) |
Pop a ``(key, list)`` tuple from the dict.
Reimplemented from MultiDict.
def poplist | ( | self, | |
key | |||
) |
Pop the list for a key from the dict. If the key is not in the dict an empty list is returned. .. versionchanged:: 0.5 If the key does no longer exist a list is returned instead of raising an error.
Reimplemented from MultiDict.
def setlist | ( | self, | |
key, | |||
new_list | |||
) |
Remove the old values for a key and add new ones. Note that the list you pass the values in will be shallow-copied before it is inserted in the dictionary. >>> d = MultiDict() >>> d.setlist('foo', ['1', '2']) >>> d['foo'] '1' >>> d.getlist('foo') ['1', '2'] :param key: The key for which the values are set. :param new_list: An iterable with the new values for the key. Old values are removed first.
Reimplemented from MultiDict.
def setlistdefault | ( | self, | |
key, | |||
default_list = None |
|||
) |
Like `setdefault` but sets multiple values. The list returned is not a copy, but the list that is actually used internally. This means that you can put new values into the dict by appending items to the list: >>> d = MultiDict({"foo": 1}) >>> d.setlistdefault("foo").extend([2, 3]) >>> d.getlist("foo") [1, 2, 3] :param key: The key to be looked up. :param default_list: An iterable of default values. It is either copied (in case it was a list) or converted into a list before returned. :return: a :class:`list`
Reimplemented from MultiDict.
def update | ( | self, | |
other_dict | |||
) |
update() extends rather than replaces existing key lists: >>> a = MultiDict({'x': 1}) >>> b = MultiDict({'x': 2, 'y': 3}) >>> a.update(b) >>> a MultiDict([('y', 3), ('x', 1), ('x', 2)]) If the value list for a key in ``other_dict`` is empty, no new values will be added to the dict and the key will not be created: >>> x = {'empty_list': []} >>> y = MultiDict() >>> y.update(x) >>> y MultiDict([])
Reimplemented from MultiDict.
def values | ( | self | ) |
Returns an iterator of the first value on every key's value list.
Reimplemented from MultiDict.