Skip to content

Instantly share code, notes, and snippets.

@shanemhansen
Created June 17, 2014 23:26
Show Gist options
  • Save shanemhansen/e831d9bd369b662f352b to your computer and use it in GitHub Desktop.
Save shanemhansen/e831d9bd369b662f352b to your computer and use it in GitHub Desktop.
goify
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