[C++-sig] Re: Reloading python code in BOOST environment
David Abrahams
dave at boost-consulting.com
Fri Oct 17 15:12:35 CEST 2003
Python extension modules are never unloaded; this isn't a boost-specific
thing.
HTH,
Dave
Kirsebom Nikolai wrote:
> I have a problem in trying to 'reload' python code in an BOOST invironment.
> Given the two files below. When I open Python (in command prompt) and do
> the following:
>
>
>>>>import Wrap
>>>>Wrap.Main()
>
> 5 abc
>
> # CHANGE CONTENT OF FILE Subber.py to have i = 6
>
>>>>Wrap.Main()
>
> 6 abc
>
>
> If I try to do the same in my application (change the Subber.py content)
> without restarting the whole application,
> the changes are not seen. Does this have something to do with BOOST
> environment, or is it probably in the Subber.py
> file (which in my application is a wxPython dialog presenting some
> information from the application (exposed objects
> using BOOST)).
> It would be so nice to not have to restart the application when only
> changing the Python-code.
>
> Thanks for any help.
> Nikolai
>
>
> ----- File Wrap.py ------------------------------------
> def Main():
> import sys,copy
> bi=copy.copy(sys.modules.keys())
> try:
> import Subber
> Subber.Main()
> except:
> raise ImportError, "Failed to import"
> ai=copy.copy(sys.modules.keys())
> for k in ai:
> if not k in bi:
> del sys.modules[k]
>
> ----- File Subber.py ---------------------------------
> i = 5
> a = 'abc'
>
> def Main():
> print i, a
More information about the Cplusplus-sig
mailing list