def cfg_from_list(cfg_list):
 from ast import literal_eval
 assert ((len(cfg_list) % 2) == 0)
 for (k, v) in zip(cfg_list[0::2], cfg_list[1::2]):
  key_list = k.split('.')
  d = __C
  for subkey in key_list[:(-1)]:
   assert d.has_key(subkey)
   d = d[subkey]
  subkey = key_list[(-1)]
  assert d.has_key(subkey)
  try:
   value = literal_eval(v)
  except:
   value = v
  assert (type(value) == type(d[subkey])), 'type {} does not match original type {}'.format(type(value), type(d[subkey]))
  d[subkey] = value

def cfg_from_list ( cfg_list ) : from ast import literal_eval assert ( ( len ( cfg_list ) % 2 ) == 0 ) for ( k , v ) in zip ( cfg_list [ 0 : : 2 ] , cfg_list [ 1 : : 2 ] ) : key_list = k . split ( '.' ) d = __C for subkey in key_list [ : ( - 1 ) ] : assert d . has_key ( subkey ) d = d [ subkey ] subkey = key_list [ ( - 1 ) ] assert d . has_key ( subkey ) try : value = literal_eval ( v ) except : value = v assert ( type ( value ) == type ( d [ subkey ] ) ) , 'type {} does not match original type {}' . format ( type ( value ) , type ( d [ subkey ] ) ) d [ subkey ] = value
set config keys via list .