monkeys paw wrote:
How do i delete a module namespace once it has been imported?
I use
import banner
Then i make a modification to banner.py. When i import it again,
the new changes are not reflected. Is there a global variable i can
modify?
It depends on what you want to achieve.
1/ if you want to re-import your module because it contains User data
that may have been updated, one way is to make sure all you definitions
are at the module level and use the execfile statement. ofc the file is
executed, so it can be done only in a trusted environment.
2/ if you want to reload your module because you changed the code and
want to test it, the best way to do it is to write a test file that will
do all the tests so that restarting the test is cheap. Testing from a
newly created python process is always the best solution, if available.
3/ if you want to do the 2/ but require a painful long prologue to your
test, then you may want to use the builtin reload. Use it with care,
because any existing object created from the previous module will not be
affected, they'll still hold the previous code. "reload" solves some
problems, but bring others, especially for the newcomer.
JM
--
http://mail.python.org/mailman/listinfo/python-list