def _set_deep(data_structure, dot_path_or_list, value_to_set):
 assert hasattr(data_structure, '__setitem__')
 search_path = None
 param_type = type(dot_path_or_list)
 if (param_type in (tuple, list)):
  search_path = dot_path_or_list
 elif (param_type == str):
  search_path = dot_path_or_list.split('.')
 assert (len(search_path) > 0), 'Missing valid search path'
 current_item = data_structure
 for search_key in search_path[:(-1)]:
  current_item.setdefault(search_key, dict())
  current_item = current_item[search_key]
 current_item[search_path[(-1)]] = value_to_set
 return data_structure

def _set_deep ( data_structure , dot_path_or_list , value_to_set ) : assert hasattr ( data_structure , '__setitem__' ) search_path = None param_type = type ( dot_path_or_list ) if ( param_type in ( tuple , list ) ) : search_path = dot_path_or_list elif ( param_type == str ) : search_path = dot_path_or_list . split ( '.' ) assert ( len ( search_path ) > 0 ) , 'Missing valid search path' current_item = data_structure for search_key in search_path [ : ( - 1 ) ] : current_item . setdefault ( search_key , dict ( ) ) current_item = current_item [ search_key ] current_item [ search_path [ ( - 1 ) ] ] = value_to_set return data_structure
attempts access nested data structures and not blow up on a gross key error .