Created
June 13, 2018 21:37
-
-
Save brun0xff/ce35f9eb4b563638b2e962a5a2dc1d47 to your computer and use it in GitHub Desktop.
This file contains 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 typecasting(obj, new_type): | |
try: | |
if obj == '' or obj is None: | |
return None | |
return new_type(obj) | |
except (ValueError, TypeError): | |
return None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment