List of all classes, functions and methods in python-igraph
class multidict(MutableMapping):
A dictionary-like object that is customized to deal with multiple values for the same key.
Each value in this dictionary will be a list. Methods which emulate the methods of a standard Python `dict` object will return or manipulate the first items of the lists only. Special methods are provided to deal with keys having multiple values.
Method | __init__ |
Undocumented |
Method | __contains__ |
Returns whether there are any items associated to the given `key`. |
Method | __delitem__ |
Removes all the items associated to the given `key`. |
Method | __getitem__ |
Returns an arbitrary item associated to the given key. Raises ``KeyError`` if no such key exists. |
Method | __iter__ |
Iterates over the keys of the multidict. |
Method | __len__ |
Returns the number of distinct keys in this multidict. |
Method | __setitem__ |
Sets the item associated to the given `key`. Any values associated to the key will be erased and replaced by `value`. |
Method | add |
Adds `value` to the list of items associated to `key`. |
Method | clear |
Removes all the items from the multidict. |
Method | get |
Returns an arbitrary item associated to the given `key`. If `key` does not exist or has zero associated items, `default` will be returned. |
Method | getlist |
Returns the list of values for the given `key`. An empty list will be returned if there is no such key. |
Method | iterlists |
Iterates over ``(key, values)`` pairs where ``values`` is the list of values associated with ``key``. |
Method | lists |
Returns a list of ``(key, values)`` pairs where ``values`` is the list of values associated with ``key``. |
Method | update |
Undocumented |
Instance Variable | _dict |
Undocumented |
Returns an arbitrary item associated to the given key. Raises ``KeyError`` if no such key exists.
Example:
>>> d = multidict([("spam", "eggs"), ("spam", "bacon")]) >>> d["spam"] 'eggs'
Sets the item associated to the given `key`. Any values associated to the key will be erased and replaced by `value`.
Example:
>>> d = multidict([("spam", "eggs"), ("spam", "bacon")]) >>> d["spam"] = "ham" >>> d["spam"] 'ham'
Adds `value` to the list of items associated to `key`.
Example:
>>> d = multidict() >>> d.add("spam", "ham") >>> d["spam"] 'ham' >>> d.add("spam", "eggs") >>> d.getlist("spam") ['ham', 'eggs']
Returns an arbitrary item associated to the given `key`. If `key` does not exist or has zero associated items, `default` will be returned.
Returns the list of values for the given `key`. An empty list will be returned if there is no such key.
Iterates over ``(key, values)`` pairs where ``values`` is the list of values associated with ``key``.