Script executes script?

M

Mipe

Hello,

for a testmodule I need to execute a python script from within a
python script. Something like:

-- ScriptA -->
import whatever

RunScript("scriptb.py")
RunScript("scriptc.py")
<-- Script A --

Is this possible? I didn't find a possibility to do this.

Would be nice if you could give me some advice here.

Thank you,
Mipe
 
J

Jeremy Sanders

Try execfile(

Alternatively, on Unix at least,

import os
os.system('other.py')

Assuming other.py is an executable. This will give you a completely new
interpreter.

Jeremy
 
M

Michel Claveau - abstraction méta-galactique non t

Bonjour !

It's OK also with windows, like popen, pawn, etc.
But execfile( is more fast, and need minus memory.


Michel Claveau
 
V

Vladimir Ivanov

Mipe said:
Hello,

for a testmodule I need to execute a python script from within a
python script. Something like:

-- ScriptA -->
import whatever

RunScript("scriptb.py")
RunScript("scriptc.py")
<-- Script A --

Is this possible? I didn't find a possibility to do this.

Would be nice if you could give me some advice here.

Thank you,
Mipe
import os
path_to_python = "c:\\Python23\\python.exe"
path_to_script = "e:\\temp\\test.py"
os.system(path_to_python + " " + path_to_script)
 
P

Peter Hansen

Vladimir said:
import os
path_to_python = "c:\\Python23\\python.exe"
path_to_script = "e:\\temp\\test.py"
os.system(path_to_python + " " + path_to_script)

Ugh. At least use sys.executable to find the
interpreter if you're going to do it this way.

-Peter
 
J

Jeremy Sanders

It's OK also with windows, like popen, pawn, etc. But execfile( is more
fast, and need minus memory.

Of course. Occasionally you want an extra process, however!

Jeremy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,205
Messages
2,571,067
Members
47,673
Latest member
MahaliaPal

Latest Threads

Top