Skip to content

Instantly share code, notes, and snippets.

@sxddhxrthx
Created July 2, 2021 15:26
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/f03d0cfd2b7575205affd96394c50f63 to your computer and use it in GitHub Desktop.
Save sxddhxrthx/f03d0cfd2b7575205affd96394c50f63 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')
for i in range(5):
with handle_div_error():
print(1/i)
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment