Restarting a Python Application

Kelvie Wong kelvie at ieee.org
Sat Jul 7 18:11:11 EDT 2007


Ugh.. this would be a repost for the OP, but I forgot to hit "reply to
all" again.

This should do it:

os.execv(sys.argv[0], sys.argv)

Not sure how portable that statement is, though.


On 7/3/07, kyosohma at gmail.com <kyosohma at gmail.com> wrote:
> Hi,
>
> I packaged up an application I am developing into an executable. In
> the application, it has user configurable options. I would like a way
> to restart the application so that the new options the user chooses
> can be applied. Firefox can restart itself. Does anyone know how to
> accomplish this in Python?
>
> Here is what I tried:
>
> <code>
>
> exePath = os.path.join(os.getcwd(), 'myprogram.exe')
> subprocess.Popen(exePath)
> sys.exit()
>
> </code>
>
> This didn't work. It closed the program, but another instance did not
> appear.
>
> Tips would be appreciated.
>
> Mike
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


-- 
Kelvie



More information about the Python-list mailing list