Skip to content

Instantly share code, notes, and snippets.

@zhuifengshen
Last active November 15, 2018 08:51
Show Gist options
  • Save zhuifengshen/bfb4a5d521a811781d3e3404351374af to your computer and use it in GitHub Desktop.
Save zhuifengshen/bfb4a5d521a811781d3e3404351374af to your computer and use it in GitHub Desktop.
Decorate func with this to prevent raising an Exception when an error is encountered
def prevent(func):
"""
Decorate func with this to prevent raising an Exception when an error is encountered
"""
@wraps(func)
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except BaseException:
return
return wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment