Created
November 7, 2017 20:59
-
-
Save sepulchered/09afd8c6e1aed477819097e36d6ff26f 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 maybe(fn, *args, **kwargs): | |
try: | |
return fn(*args, **kwargs) | |
except Exception: | |
return None | |
def divide(num, den): | |
return num / den | |
print(maybe(divide, 1, 2)) | |
print(maybe(divide, 1, 0)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment