Created
November 28, 2017 18:56
-
-
Save nagayev/63a0fa07ac86d07c72c1ffb01598cf25 to your computer and use it in GitHub Desktop.
Require python scripts
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
def require(filename,mode=1,module=""): | |
with open(filename,"r") as f: | |
content=f.read() | |
arr=[] | |
buf=[] | |
f.close() | |
arr=content.split(",") | |
for i in range(len(arr)): | |
if mode==1: | |
exec("import " + arr[i]) | |
buf.append(arr[i]) | |
exec("global " + arr[i]) | |
exec(arr[i] + "=" + buf[0]) | |
del buf[0] | |
elif mode!=1: | |
exec("from " + i + " import " + module) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment