Skip to content

Instantly share code, notes, and snippets.

@scott-w
Created March 18, 2017 13:27
Show Gist options
  • Save scott-w/ffee05c6ad09eae1318ae338ed3f5caa to your computer and use it in GitHub Desktop.
Save scott-w/ffee05c6ad09eae1318ae338ed3f5caa to your computer and use it in GitHub Desktop.
Catching Exceptions
from __future__ import absolute_import, print_function, unicode_literals
from .modules import my_function, handle_exception
## Python 2 only
try:
my_function()
except AttributeError, exc:
handle_exception()
## Do this instead
try:
my_function()
except AttributeError as exc:
handle_exception()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment