Advertisement
MrPoxipol

Python: import ONLY global modules

Dec 27th, 2014
486
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. from sys import path
  2. from os import getcwd
  3. from importlib import import_module
  4.  
  5. def import_global_module(name):
  6.     path.remove(getcwd())
  7.     module = import_module(name)
  8.     path.insert(0, getcwd())
  9.  
  10.     return module
  11.  
  12. yourmodule = import_global_module('yourmodule')
  13. # print(yourmodule)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement