Python 2.5 execfile() works only once, why ?

Carl Banks pavlovevidence at gmail.com
Fri Oct 9 22:21:59 CEST 2009


On Oct 9, 11:15 am, Stef Mientki <stef.mien... at gmail.com> wrote:
> 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 ?

I'm guessing you have references to objects from the first time you
ran execfile that don't get updated.  It's kind of hard to tell.


Carl Banks



More information about the Python-list mailing list