Created
June 17, 2014 23:26
-
-
Save shanemhansen/e831d9bd369b662f352b to your computer and use it in GitHub Desktop.
goify
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
nil = None | |
def goify(f): | |
""" | |
You know why | |
""" | |
@functools.wraps(f) | |
def wrapper(*args, **kwargs): | |
""" | |
Wrap wrap a function that can return an error | |
in a tuple of (result, error) | |
""" | |
try: | |
return (f(*args, **kwargs), None) | |
except Exception, e: | |
return None, e | |
return wrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment