a newbie's question
jeanmichel at sequans.com
Thu Mar 11 14:10:40 CET 2010
PEYMAN ASKARI wrote:
> I need some help dynamically reloading modules. As it turns out, it is
> not as simple as calling reload, as outlined here
> Is there builtin support for this? The example they gave does not seem
> to work for me, and I am unclear as to what PyUnit is.
Please don't top post.
As for your question, there's no built-in method to reload a module
because it is not possible (in a generic manner).
However if you *really* want to do it you can do it for your particular
module (and only for this one).
It is tough to explain though. You have to know perfectly the python
object model and I'm not familiar enough with it to do the explanation.
1/ try to live without dynamic reload
2/ if you *really* require dynamic reload, you can try to execute the
module in a subprocess. That way, every time you start a new subprocess,
the last up to date version of the module is used
3/ reload the module and all it's related objects currently in memory,
this is painfull and there are many traps to fall into. I'll let someone
else answer this point.
More information about the Python-list