Dictionaries¶
- delete(key, d)¶
Remove key from dictionary d and return its value.
- Parameters:
key (Any) – The list index for the element to remove.
d (dict) – The dictionary to remove from.
- Raises:
KeyError – key must exist within d.
- Returns:
The value of the popped key.
- Return type:
Any
- get_items(d)¶
Get a dynamic view object of the dictionary d’s key, value pairs that reflects changes to d
- Parameters:
d (dict) – the dictionary.
- Returns:
A view of the (key, value) tuple pairs in d.
- Return type:
ValuesView
- get_keys(d)¶
Get a dynamic view object of the dictionary d’s keys that reflects changes to d.
- Parameters:
d (dict) – the dictionary.
- Returns:
A view of the keys in d.
- Return type:
KeysView
- get_value(key, d, default=None)¶
Get the value corresponding to key from d. If key is not in d, returns default.
- Parameters:
key (Any) – the key to get from d.
d (dict) – the dictionary to check for key.
default (Any, optional) – the value to return if key is not in d. If not specified, defaults to None.
- Returns:
The value corresponding to key, or default if not in d.
- Return type:
Any
- get_values(d)¶
Get a dynamic view object of the dictionary d’s values that reflects changes to d.
- Parameters:
d (dict) – the dictionary.
- Returns:
A view of the values in d.
- Return type:
ValuesView