def hasattr_recursive(item, attr_key):
 if ('.' in attr_key):
  (attr_key, last_key) = attr_key.rsplit('.', 1)
  item = getattr_recursive(item, attr_key, None)
  if (item is None):
   return False
  attr_key = last_key
 try:
  if isinstance(item, dict):
   return item.__contains__(attr_key)
  else:
   return hasattr(item, attr_key)
 except (KeyError, AttributeError):
  return False
 return True

def hasattr_recursive ( item , attr_key ) : if ( '.' in attr_key ) : ( attr_key , last_key ) = attr_key . rsplit ( '.' , 1 ) item = getattr_recursive ( item , attr_key , None ) if ( item is None ) : return False attr_key = last_key try : if isinstance ( item , dict ) : return item . __contains__ ( attr_key ) else : return hasattr ( item , attr_key ) except ( KeyError , AttributeError ) : return False return True
allows dot member notation in attribute name when getting an items attribute .