def unorderable_list_difference(expected, actual, ignore_duplicate=False):
 missing = []
 unexpected = []
 while expected:
  item = expected.pop()
  try:
   actual.remove(item)
  except ValueError:
   missing.append(item)
  if ignore_duplicate:
   for lst in (expected, actual):
    try:
     while True:
      lst.remove(item)
    except ValueError:
     pass
 if ignore_duplicate:
  while actual:
   item = actual.pop()
   unexpected.append(item)
   try:
    while True:
     actual.remove(item)
   except ValueError:
    pass
  return (missing, unexpected)
 return (missing, actual)

def unorderable_list_difference ( expected , actual , ignore_duplicate = False ) : missing = [ ] unexpected = [ ] while expected : item = expected . pop ( ) try : actual . remove ( item ) except ValueError : missing . append ( item ) if ignore_duplicate : for lst in ( expected , actual ) : try : while True : lst . remove ( item ) except ValueError : pass if ignore_duplicate : while actual : item = actual . pop ( ) unexpected . append ( item ) try : while True : actual . remove ( item ) except ValueError : pass return ( missing , unexpected ) return ( missing , actual )
same behavior as sorted_list_difference but for lists of unorderable items .