Created
March 5, 2014 23:56
-
-
Save sudorandom/9379323 to your computer and use it in GitHub Desktop.
Multi Multiple Import
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
PARSERS = [('pkg_resources', 'parse_version'), ('distutils.version', 'StrictVersion')] | |
def get_parse_fn(): | |
for parser_module, parser in PARSERS: | |
try: | |
return getattr(importlib.import_module(parser_module), 'parser') | |
except ImportError: | |
pass | |
raise Exception("Couldn't find a thing to do the thing") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment