Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. out_files = list(itertools.chain(*unpaired_files))
  2. for items in itertools.product(*new_files):
  3. if items and self._compare_multiple_dicts_except(all_exceptions, *items):
  4.  
  5. def _compare_multiple_dicts_except(self, exceptions, *dicts):
  6. keys = []
  7. for d in dicts:
  8. keys.append(
  9. sorted([key for key in d.keys() if key not in exceptions]))
  10. if not all(x == keys[0] for x in keys):
  11. return False
  12. for key in keys[0]:
  13. items = [d[key] for d in dicts]
  14. if not all(x == items[0] for x in items):
  15. return False
  16. return True
  17.  
  18. >>> _compare_multiple_dicts_except(['a', 'b'], {'a': 1, 'c': 3, 'd': 4}, {'a': 2, 'c': 3, 'd': 4})
  19. True
  20. >>> _compare_multiple_dicts_except(['a', 'b'], {'a': 1, 'c': 3, 'd': 4}, {'c': 4, 'd': 4})
  21. False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement