Skip to content

Instantly share code, notes, and snippets.

@sxddhxrthx
Created July 2, 2021 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sxddhxrthx/fe135b50a8eb308172d7234c572ffb6d to your computer and use it in GitHub Desktop.
Save sxddhxrthx/fe135b50a8eb308172d7234c572ffb6d to your computer and use it in GitHub Desktop.
from contextlib import contextmanager
@contextmanager
def handle_division_error():
try:
yield
except ZeroDivisionError as zde:
print('zero division error')
with handle_division_error():
print(1/0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment