unloading a module created with imp.new_module

Ned Batchelder ned at nedbatchelder.com
Mon Nov 24 03:56:12 CET 2014

On 11/23/14 1:49 AM, Patrick Stinson wrote:
> If I create a module with imp.new_module(name), how can I unload it so that all the references contained in it are set to zero and the module is deleted? deleting the reference that is returned doesn’t seem to do the job, and it’s not in sys.modules, so where is the dangling reference?
> Thanks!

This sounds tricky, and possible very difficult to do properly.  Do you 
mind if I ask what the larger problem is?  Python might not be very good 
at having modules come and go as you want.

Ned Batchelder, http://nedbatchelder.com

More information about the Python-list mailing list