getnested#

getnested(nested, keylist, safe=False, default=None)[source]#

Get the value for the given list of keys

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

  • keylist (str/list/tuple) – the keys to get (typically a list)

  • safe (bool) – whether to return the “default” value if the key is not found

  • default (any) – the value to return if the key is not found (sets safe=True if provided)

Example:

sc.getnested(foo, ['a','b']) # Gets foo['a']['b']

See sc.makenested() for full documentation.