Created
August 19, 2016 17:48
-
-
Save rbrooks/36a7466af87bd97f58f3371b6a5c55cb to your computer and use it in GitHub Desktop.
Whitelist Dictionary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def whitelist_dict(dic, keys): | |
# Filters a Dict by only including certain keys. | |
key_set = set(keys) & set(dic.keys()) | |
return { key: dic[key] for key in key_set } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment