[C++-sig] Reloading Functions
seefeld at sympatico.ca
Tue Apr 10 22:05:55 CEST 2007
Jared McIntyre wrote:
> I’m sure this should be answered somewhere, but I’m having problems
> hunting it down. I am working to get embedded Python scripting in the
> system using boost::python. We already have LUA running. The only issue
> I’m having is reloading python functions into the runtime. So, I load
> the file initially:
> object result = exec_file("C:\\ PythonTest\\HelloFile.py", global, global);
> object greet = global["greet"];
> Now I can run greet() just fine. However, we need to be able to make
> changes in the greet script while the system is running, and swap the
> old with the new. Calling the exec_file again won’t replace the function
> with the new version. Is there a way to do this without tearing down the
> entire python runtime and restarting it?
exec_file should execute the file (and put all symbols into 'global', each
time it is called, no matter whether the file has the same content as the last
time you called it.
If you don't want to preserve the content of 'global', there is no need to reuse
that, i.e. you could use a different dictionary on each invocation.
...ich hab' noch einen Koffer in Berlin...
More information about the Cplusplus-sig