Run a python script as an exe and run a new process from it

Paddy O'Loughlin patrick.oloughlin at gmail.com
Thu Feb 26 13:14:56 EST 2009


Try this as an outline:
#### script1.py
from subprocess import Popen

if __name__ == '__main__':
	scriptname = "script2.py"

	Popen("python %s" % scriptname, shell=True)


	print "I'm done"


#### script2.py
from time import sleep

if __name__ == '__main__':
    while (True):
        print "waiting.."
        sleep(2)

###########################
If you install python using the Windows Installer (.exe), it should
set up .py files to be opened by python when double-clicking on them.
Alternatively, you can right-click on your .py file and go to "Open
With..." then "choose program", then click "Browse...", you can Browse
to the python executable, so Explorer will use it to open .py files
when you double-click on them.

As someone else mentioned there is also a py2exe program. Google it.

2009/2/26 venutaurus539 at gmail.com <venutaurus539 at gmail.com>:
> Hello all,
>           I've a strange requirement where I need to run a python
> script just as we run an exe (by double clicking through windows
> explorer or by typing the script name at command prompt). In that
> process I should be able to execute another python script in such a
> way that, the second script should continue running but the main one
> should terminate without effecting the second one.
>
>                    My requirement may be little confusing so please
> get back if you didn't understand what I meant above.
>
>
> Thank you,
> Venu.
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
"Ray, when someone asks you if you're a god, you say YES!"



More information about the Python-list mailing list