Created
June 14, 2013 22:50
-
-
Save Flushot/5785898 to your computer and use it in GitHub Desktop.
Imports a module that would also have the same name as a local module, but exists in a different location.
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
| def import_non_local(name, customName=None): | |
| import imp | |
| customName = customName or name | |
| f, pathName, desc = imp.find_module(name, sys.path[1:]) | |
| module = imp.load_module(customName, f, pathName, desc) | |
| f.close() | |
| return module | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment