[Tutor] executing a script from a script

rui ruivaldo at gmail.com
Tue Aug 26 23:15:04 CEST 2008


On Tue, Aug 26, 2008 at 3:31 PM, Jeff Peery <jeffpeery at seametrics.com> wrote:
> Hello,
>
> I have a simple wx app that I need some help with. This application uses the
> serial ports to communicate with an industrial product. I first check that
> my python application is compatible with the industrial product by asking
> the industrial product for its revision number. If the revision number is
> too old I want to kill my python application and launch an older python
> application. To do this I am using the following:
>
>
>
> # launch old program
>
> execfile('theoldpythonprogram.py')
>
> # kill this App (wx.Frame object)
>
> self.Destroy()
>
>
>
> The problem is that the self.Destroy() seems to kill both the current python
> program and the one I just launched. How can I launch a new program and kill
> the current one without killing the new one as well?
>
>

Hi Jeff,

The problem is that execfile runs the script inside the current python
interpreter.
To run this as -- really -- an external process, look at:

http://blog.doughellmann.com/2007/07/pymotw-subprocess.html

Cheers and good luck. Just a tip, using inheritance could solve your
problem more elegantly.

[ As quatro melhores coisas do mundo são três: forró e mulher. ]

>
> Thanks!
>
>
>
> Jeff
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>


More information about the Tutor mailing list