Skip to content

Instantly share code, notes, and snippets.

@Flushot
Created June 14, 2013 22:50
Show Gist options
  • Select an option

  • Save Flushot/5785898 to your computer and use it in GitHub Desktop.

Select an option

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.
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