Created
January 13, 2017 10:25
-
-
Save hiqua/d95e706922ad906fe9a02a01d7a2290c to your computer and use it in GitHub Desktop.
Load modules in when starting the python interpreter, if available.
This file contains hidden or 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
MOD_LIST = [ | |
['math'], | |
['tensorflow', 'tf'], | |
] | |
def load_module(module): | |
import importlib | |
assert len(module) in (1, 2), module | |
try: | |
globals()[module[-1]] = importlib.import_module(module[0]) | |
except ImportError: | |
print("Module {} not loaded".format(module[0])) | |
for module in MOD_LIST: | |
load_module(module) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment