Unloading a module in Python 3.x

It is clear to me that in Python 2 there is no clean solution to unload a module, and it was a known bug that was fixed.

Messages:

How to unload (reload) a Python module? Delete imported python module

2009 and 2010 confirm the lack of support for unloading the module.

I wonder if this was allowed in Python 3.x. When I do it, import os, del os, dir(), the module osdoes not (at least not visible, you can use). It did not pass?

+3
source share
1 answer

sys.modules still contains a link to the module.

>>> import six
>>> del six
>>> sys.modules["six"]
<module 'six' from '/usr/lib64/python3.3/site-packages/six.py'>

sys.modules still contains the link. Therefore, I do not think that you can also unload a module in Python 3.3.

0
source

All Articles