3

How might we obtain a list of paths to all files which have been loaded from after initial start-up, before the current code which is being executed, and the current code which is being executed?

The following was an idea I had:

import inspect

lizard = list()    
for mdl in sys.modules.values():
    try:
        lizard.append(inspect.getfile(mdl))
    except:
        pass

However, modules may be removed from sys.modules during execution. How do we get the ones which may have been removed at some point?

The reason I ask is that I am trying to located unused files in a project and get rid of them.

Toothpick Anemone
  • 4,290
  • 2
  • 20
  • 42

0 Answers0