Python 2.5 execfile() works only once, why ?

Stef Mientki stef.mientki at gmail.com
Fri Oct 9 14:15:48 EDT 2009


hello,

I'm working on a kind of IDE, to build and distribute Python programs.

One of the parts is editing a build file for py2exe and running the 
modified script.

In  the script editor I've an accelerator key, to launch these tasks:
- save modified script file
- run modified script file
- catch log and error information from py2exe
- launch the distro executable

      self.Edit.SaveFile ( self.Edit.Filename )
      Globalsx = {}
      #Globalsx [ 'stdout' ]  = self.Log
      execfile ( self.Edit.Filename, Globalsx  )

The above code (with or without the stdout redirection),
works perfect, ....
... the first time ...
but does (almost?) nothing (doesn't crash, try / except around execfile),
although the source file "self.Edit.Filename" has changed.

Could someone give me an explanation, why this happens ?

It would be great to have a work around.
I've currently switched to Popen, but can't get output / error piping 
working fluently.

thanks,
Stef Mientki




More information about the Python-list mailing list