def _get_item_key(item, key):
 if (key in item):
  return item[key]
 nested_item = item
 for subkey in key.split('.'):
  if (not subkey):
   raise ValueError(('empty subkey in %r' % key))
  try:
   nested_item = nested_item[subkey]
  except KeyError as e:
   raise KeyError(('%r - looking up key %r in %r' % (e, key, nested_item)))
 else:
  return nested_item

def _get_item_key ( item , key ) : if ( key in item ) : return item [ key ] nested_item = item for subkey in key . split ( '.' ) : if ( not subkey ) : raise ValueError ( ( 'empty subkey in %r' % key ) ) try : nested_item = nested_item [ subkey ] except KeyError as e : raise KeyError ( ( '%r - looking up key %r in %r' % ( e , key , nested_item ) ) ) else : return nested_item
allow for lookups in nested dictionaries using .