Skip to content

Instantly share code, notes, and snippets.

@nagayev
Created November 28, 2017 18:56
Show Gist options
  • Save nagayev/63a0fa07ac86d07c72c1ffb01598cf25 to your computer and use it in GitHub Desktop.
Save nagayev/63a0fa07ac86d07c72c1ffb01598cf25 to your computer and use it in GitHub Desktop.
Require python scripts
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