no more reload() in py3k

timaranz at gmail.com timaranz at gmail.com
Tue Sep 18 21:23:48 EDT 2007


Hi all, this is possibly a python-dev question but I'll ask here
first.

Situation:
I work on an application that takes 10-20 seconds to startup plus
opening a document.  To avoid having to restart the entire application
each edit-debug cycle we rely heavily on the reload command. A typical
method in our command dispatcher looks like this:

def edit_something(self, something):
   reload(meshDialogModule)
   dlg = meshDialogModule.MeshDialog(self.app, something)
   dlg.run()

when the application is built into an exe the reload function is
redefined to lambda x: x.
The advantage of this is that every time I open a dialog my latest
changes are applied and the debug cycle is: edit code -> open dialog -
>
test -> close dialog -> edit code, which is many times faster than
restarting the app and opening a project each time.

Question:
I am told to use the exec() statement instead.  I don't see how I can
use exec to reload a module.

Cheers
Tim




More information about the Python-list mailing list