By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,854 Members | 833 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,854 IT Pros & Developers. It's quick & easy.

execute another python script

P: n/a
how do I execute another python script under a different process? I
want the script to be run using the same interpretoer as the one
running current script. I tried using os.execlp but I don't know how
to get the name/path of the interpreter.
Aug 18 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Alexandru Mosoi wrote:
how do I execute another python script under a different process? I
want the script to be run using the same interpretoer as the one
running current script. I tried using os.execlp but I don't know how
to get the name/path of the interpreter.
>>import sys, subprocess
subprocess.call([sys.executable, "-c", "print 'hello'"])
hello
0
>>>
If Python is embedded in another program, it's unspecified whether
sys.executable refers to the program or a compatible Python interpreter
(see the python-dev archives for discussions), but the above should work
in all cases if you're using a stand-alone interpreter.

</F>

Aug 18 '08 #2

P: n/a
On Aug 18, 11:34*am, Fredrik Lundh <fred...@pythonware.comwrote:
*>>import sys, subprocess
*>>subprocess.call([sys.executable, "-c", "print 'hello'"])
hello
0

10x :). exactly what I was looking for.
Aug 18 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.