Last active
February 25, 2017 15:29
-
-
Save Kennyl/69fe126ea2a1cabd81150fc1d594943f to your computer and use it in GitHub Desktop.
Python suppress excerption compatibility workaround
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
if (sys.version_info > (3, 0)): | |
from contextlib import suppress | |
else: | |
from contextlib import contextmanager | |
@contextmanager | |
def suppress(*exceptions): | |
try: | |
yield | |
except exceptions: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thx to
http://stackoverflow.com/questions/730764/try-except-in-python-how-do-you-properly-ignore-exceptions