- qspec. add_nested_key ( a , key_list , val )[source]
-
Assign a value to a nested key of a dictionary, creating the intermediate dictionaries if necessary.
- Parameters:
-
- adict
The target dictionary.
- key_listlist
A list of nested keys of
a.- valarray_like
The value that is assigned to the last key in
key_list.
- Returns:
-
- adict
The dictionary
awithvalassigned to the last key inkey_list.
- Raises:
-
- TypeError
If an intermediate value is not a dictionary.