opposite of import

Simon Brunning simon at brunningonline.net
Thu Aug 3 08:26:54 EDT 2006


On 8/3/06, Simon Brunning <simon at brunningonline.net> wrote:
> If you want to remove the module from a namespace into which you
> imported it, you can do that with del:
>
> 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.

-- 
Cheers,
Simon B,
simon at brunningonline.net,
http://www.brunningonline.net/simon/blog/



More information about the Python-list mailing list