This should work:
eval(memfile.open().read())
EDIT:
It turns out exec
is needed, as eval
accepts expressions only:
exec memfile
Frage
I want to run a memfile done with StringIO. Is there any possibility for doing it? something like this:
import StringIO
memfile = StringIO.StringIO()
memfile.write("print 'hello world'")
#with diskfiles I would do:
#os.system('python memfile') ?
#subprocess.Popen('memfile', shell=True)
memfile.close()
Keine korrekte Lösung
Andere Tipps
This should work:
eval(memfile.open().read())
EDIT:
It turns out exec
is needed, as eval
accepts expressions only:
exec memfile