Skip to content

Instantly share code, notes, and snippets.

@hidenorigoto
Created June 21, 2014 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hidenorigoto/ea5292d2dc01384eae42 to your computer and use it in GitHub Desktop.
Save hidenorigoto/ea5292d2dc01384eae42 to your computer and use it in GitHub Desktop.
ロードされているモジュールリスト
#!/usr/bin/env python
# -*- coding: utf-8 -*
# from http://tell-k.hatenablog.com/entry/2012/02/04/131805
from pydoc import ModuleScanner
from string import find
modules = []
def callback(path, modname, desc, modules=modules):
if modname and modname[-9:] == '.__init__':
modname = modname[:-9]
if modname not in modules:
modules.append(modname)
def onerror(modname):
callback(None, modname, None)
ModuleScanner().run(callback, onerror=onerror)
print modules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment