Created
October 9, 2020 03:17
-
-
Save bugcy013/df97d2eadec3a5397bd2b228eaf69a4d to your computer and use it in GitHub Desktop.
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 keys_exists(element, *keys): | |
| if not isinstance(element, dict): | |
| raise AttributeError('keys_exists() expects dict as first argument.') | |
| if len(keys) == 0: | |
| raise AttributeError('keys_exists() expects at least two arguments, one given.') | |
| _element = element | |
| for key in keys: | |
| try: | |
| _element = _element[key] | |
| except KeyError: | |
| return False | |
| return True | |
| if __name__ == '__main__': | |
| keys_exists(dict, key, key, key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment