nested_set

Contents

nested_set#

nested_set(dic: dict, keys: list, value: Any) None[source]#

Set value in nested directory:

Parameters:
  • dic (dict) – Dictionary

  • keys (list[str]) – Keys as a list

  • value – Value to be set

Example

>>> dct = {"A": "T", "R": 3}
>>> nested_set(dct, keys=["B", "C", "D"], value="value")
{
"A": "T",
"R": 3,
"B": {
     "C": {
          "D": "value"
          }
     }
}