Gerhard Fiedler wrote: > On 2006-08-03 09:26:54, Simon Brunning wrote: > >>> import amodule >>> amodule.afunction() # Works fine >>> >>> del amodule >>> amodule.afunction() # Will die now >> >> Note that this doesn't get rid of a module entirely. Python will >> still holds on to the module, and if you just import it again at this >> point, it won't be re-executed - you'll just get another reference to >> the original module. > > Is that guaranteed, or is that just until the garbage collector has > removed the module (at some arbitrary point)? > It is guaranteed that simply deleting the module from the module which imported it won't be sufficient to throw it away as other references to the module will remain (in particular the list of modules used by the import mechanism to ensure you get the same module if you re-import it again in the future).
-- http://mail.python.org/mailman/listinfo/python-list