setnested#

setnested(obj=None, keylist=None, value=None, **kwargs)[source]#

Set the value for the given list of keys; alias for sc.makenested().

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

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

  • value (any) – the value to set

  • **kwargs (dict) – passed to sc.makenested()

Example:

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

See sc.makenested() for full documentation.