Created
March 18, 2017 13:27
-
-
Save scott-w/ffee05c6ad09eae1318ae338ed3f5caa to your computer and use it in GitHub Desktop.
Catching Exceptions
This file contains 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
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