PDA

View Full Version : Is there a way to test if a library has already been opened?



hmischel@diligentsystems.com
2019-05-03, 11:09
Hi,

I have several different python libraries that I use, and didn't want to keep them all open at the same time.

Is there a way I can check if a library is already opened?

Thanks

Herb

barrymavin
2019-05-03, 18:39
Hi Herb,

The python import statement only loads a module once.

Python does not officially support unloading modules.
You can however test to see if a module is loaded using:

type(sys.modules["modulename"])

and if there are no references to it:

del sys.modules["modulename"]