Skip to content

Instantly share code, notes, and snippets.

@robintw
Created April 12, 2014 10:54
Show Gist options
  • Save robintw/10529839 to your computer and use it in GitHub Desktop.
Save robintw/10529839 to your computer and use it in GitHub Desktop.
from modulefinder import ModuleFinder
f = ModuleFinder()
# Run the main script
f.run_script('run.py')
# Get names of all the imported modules
names = list(f.modules.keys())
# Get a sorted list of the root modules imported
basemods = sorted(set([name.split('.')[0] for name in names]))
# Print it nicely
print "\n".join(basemods)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment