SHARE
TWEET

compare dicts with ignored_keys

DeaD_EyE Jul 6th, 2018 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def compare_dicts2(dict1, dict2, ignored_keys):
  2.     ignored_keys = set(ignored_keys)
  3.     keys1 = set(dict1) - ignored_keys
  4.     keys2 = set(dict2) - ignored_keys
  5.     if not keys1 == keys2:
  6.         return False
  7.     for key in keys1:
  8.         if dict1[key] != dict2[key]:
  9.             return False
  10.     return True
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top