Last active
November 23, 2016 01:49
-
-
Save andyfangdz/27cf4d38b6bd831fc0dc0d70e0cb322c 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 safe_get(_dict, _key, _type): | |
val = _dict.get(_key, None) | |
try: | |
return _type(val) | |
except TypeError: | |
return _type() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment