setnested#

setnested(nested, keylist, value, force=True)[source]#

Set the value for the given list of keys

Parameters:
  • nested (any) – the nested object (dict, list, or object) to modify

  • keylist (list) – the list of keys to use

  • value (any) – the value to set

  • force (bool) – whether to create the keys if they don’t exist (NB: only works for dictionaries)

Example:

sc.setnested(foo, ['a','b'], 3) # Sets foo['a']['b'] = 3

See sc.makenested() for full documentation.