execfile

How do I execute a python script that is stored on the internet?

自闭症网瘾萝莉.ら 提交于 2019-12-01 14:33:04
I am using python 2.4 for a program which imports scripts from the internet and executes them so a script could be changed by the author and the user wouldn't have to re-download the script. This is the part of the program that downloads the script: def downloadScript(self,script): myfile=open('#A file path/'+script['name']+'.txt','w') try: downloadedScript=urllib.urlopen(script['location']).read() except: #raise error return myfile.write(downloadedScript) myfile.close() def loadScript(self): if not self.scriptCurrentlyLoaded: script=self.scripts[self.scroller.listPos] if script['location']==

How do I execute a python script that is stored on the internet?

早过忘川 提交于 2019-12-01 12:47:58
问题 I am using python 2.4 for a program which imports scripts from the internet and executes them so a script could be changed by the author and the user wouldn't have to re-download the script. This is the part of the program that downloads the script: def downloadScript(self,script): myfile=open('#A file path/'+script['name']+'.txt','w') try: downloadedScript=urllib.urlopen(script['location']).read() except: #raise error return myfile.write(downloadedScript) myfile.close() def loadScript(self):

Alternative to execfile in Python 3? [duplicate]

牧云@^-^@ 提交于 2019-11-26 08:09:22
问题 This question already has an answer here: What is an alternative to execfile in Python 3? 11 answers Python 2 had the builtin function execfile, which was removed in Python 3.0. This question discusses alternatives for Python 3.0, but some considerable changes have been made since Python 3.0. What is the best alternative to execfile for Python 3.2, and future Python 3.x versions? 回答1: The 2to3 script (also the one in Python 3.2) replaces execfile(filename, globals, locals) by exec(compile