Removing modules from the global namespace
Bjorn Pettersen
BPettersen at NAREX.com
Mon May 14 17:15:28 EDT 2001
> From: Chris Jaeger [mailto:cjaeger at ensim.com]
>
> Hi all,
>
> I was wondering if there was a way to remove
> imported modules from a namespace. For instance, I
> have an __init__.py that loads a dynamic list of modules
> based on what it finds present in the directory. In order
> to determine the contents of the directory, I need to import
> os, string, etc. Before I return from __init__.py, I'd like
> to remove all the modules from the namespace for this package
> except for the ones that come from this directory. Can this
> be done?
Can't you just put your functionality in a function, and import the modules
inside the function instead of at the global level?
-- bjorn
More information about the Python-list
mailing list