0

I want to remove several redundant pre-production modules. So I try this but it doesn't work:

for module in sys.modules:
    if 'outlook_preprod' in module:
        del module

because then I can still see them:

for module in sys.modules:
    if 'outlook_preprod' in module:
        print(module)

outlook_preprod_v1
outlook_preprod_v2

How can I fix this error?

NonSleeper
  • 849
  • 1
  • 6
  • 17
  • 2
    I guess, you mean `del sys.modules[module]` ? – Maurice Meyer Aug 30 '22 at 13:56
  • 1
    If you've already imported a module, and have a name referring to it, then the module will keep existing for as long as that name refers to it. Nothing you can possibly do via `sys.modules` will change that fact. – jasonharper Aug 30 '22 at 14:15

0 Answers0