List loaded modules in python

Just a handy little function to list the loaded modules compiled and available in the namespace.

[python]
import sys
list(sys.modules.keys())
[/python]

yields something like

>[‘copy_reg’, ‘encodings’, ‘site’, ‘__builtin__’, ‘__main__’, ‘encodings.encodings’, ‘abc’, ‘posixpath’, ‘errno’, ‘encodings.codecs’, ‘_abcoll’, ‘types’, ‘_codecs’, ‘_warnings’, ‘genericpath’, ‘stat’, ‘zipimport’, ‘encodings.__builtin__’, ‘warnings’, ‘UserDict’, ‘encodings.utf_8’, ‘sys’, ‘codecs’, ‘readline’, ‘os.path’, ‘signal’, ‘linecache’, ‘posix’, ‘encodings.aliases’, ‘exceptions’, ‘os’]

twitter
twitter

Leave a Reply

Your email address will not be published. Required fields are marked *