Last active
October 15, 2015 03:50
-
-
Save gchiam/c8e2ce83cf9cfc87fc1f to your computer and use it in GitHub Desktop.
fallback import (python3 only)
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
# spam.py | |
try: | |
import foo | |
except ImportError: | |
import simplefoo as foo |
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
# if the module foo can be found, do import | |
if find_spec('foo'): | |
import foo | |
else: | |
import simplefoo as foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment