Home › Forums › Python Programming › How to know the loaded modules and its details from a python interpreter.
- This topic has 0 replies, 1 voice, and was last updated 12 years, 2 months ago by
Humble.
Viewing 1 post (of 1 total)
-
AuthorPosts
-
Humble
KeymasterA module is a file containing Python definitions and statements.
The file name is the module name with the suffix .py appended. Modules are objects. After importing a module ,the reference to a module can be taken from the global dictionary sys.modules. Within a module, the module’s name (as a string) is available as the value of the global variable __name__.>>>> import sys >>> sys.modules {'copy_reg': <module 'copy_reg' from '/usr/lib64/python2.7/copy_reg.pyc'>, 'sre_compile': <module 'sre_compile' from '/usr/lib64/python2.7/sre_compile.pyc'>, '_sre': <module '_sre' (built-in)>, 'encodings': <module 'encodings' from '/usr/lib64/python2.7/encodings/__init__.pyc'>, 'site': <module 'site' from '/usr/lib64/python2.7/site.pyc'>, '__builtin__': <module '__builtin__' (built-in)>, 'sysconfig': <module 'sysconfig' from '/usr/lib64/python2.7/sysconfig.pyc'>, '__main__': <module '__main__' (built-in)>, 'encodings.encodings': None, 'abc': <module 'abc' from '/usr/lib64/python2.7/abc.pyc'>, 'posixpath': <module 'posixpath' from '/usr/lib64/python2.7/posixpath.pyc'>, '_weakrefset': <module '_weakrefset' from '/usr/lib64/python2.7/_weakrefset.pyc'>, 'errno': <module 'errno' (built-in)>, 'encodings.codecs': None, 'sre_constants': <module 'sre_constants' from '/usr/lib64/python2.7/sre_constants.pyc'>, 're': <module 're' from '/usr/lib64/python2.7/re.pyc'>, '_abcoll': <module '_abcoll' from '/usr/lib64/python2.7/_abcoll.pyc'>, 'types': <module 'types' from '/usr/lib64/python2.7/types.pyc'>, '_codecs': <module '_codecs' (built-in)>, 'encodings.__builtin__': None, '_warnings': <module '_warnings' (built-in)>, 'codecs': <module 'codecs' from '/usr/lib64/python2.7/codecs.pyc'>, 'genericpath': <module 'genericpath' from '/usr/lib64/python2.7/genericpath.pyc'>, 'stat': <module 'stat' from '/usr/lib64/python2.7/stat.pyc'>, 'zipimport': <module 'zipimport' (built-in)>, '_sysconfigdata': <module '_sysconfigdata' from '/usr/lib64/python2.7/_sysconfigdata.pyc'>, 'warnings': <module 'warnings' from '/usr/lib64/python2.7/warnings.pyc'>, 'UserDict': <module 'UserDict' from '/usr/lib64/python2.7/UserDict.pyc'>, 'encodings.utf_8': <module 'encodings.utf_8' from '/usr/lib64/python2.7/encodings/utf_8.pyc'>, 'sys': <module 'sys' (built-in)>, 'peak.util': <module 'peak.util' (built-in)>, 'peak': <module 'peak' (built-in)>, 'repoze': <module 'repoze' (built-in)>, 'readline': <module 'readline' from '/usr/lib64/python2.7/lib-dynload/readline.so'>, 'paste': <module 'paste' (built-in)>, 'os.path': <module 'posixpath' from '/usr/lib64/python2.7/posixpath.pyc'>, 'signal': <module 'signal' (built-in)>, 'traceback': <module 'traceback' from '/usr/lib64/python2.7/traceback.pyc'>, 'linecache': <module 'linecache' from '/usr/lib64/python2.7/linecache.pyc'>, 'posix': <module 'posix' (built-in)>, 'encodings.aliases': <module 'encodings.aliases' from '/usr/lib64/python2.7/encodings/aliases.pyc'>, 'oslo': <module 'oslo' (built-in)>, 'exceptions': <module 'exceptions' (built-in)>, 'sre_parse': <module 'sre_parse' from '/usr/lib64/python2.7/sre_parse.pyc'>, 'abrt_exception_handler': <module 'abrt_exception_handler' from '/usr/lib64/python2.7/site-packages/abrt_exception_handler.pyc'>, 'os': <module 'os' from '/usr/lib64/python2.7/os.pyc'>, '_weakref': <module '_weakref' (built-in)>} >>> sys.modules.keys() ['copy_reg', 'sre_compile', '_sre', 'encodings', 'site', '__builtin__', 'sysconfig', '__main__', 'encodings.encodings', 'abc', 'posixpath', '_weakrefset', 'errno', 'encodings.codecs', 'sre_constants', 're', '_abcoll', 'types', '_codecs', 'encodings.__builtin__', '_warnings', 'codecs', 'genericpath', 'stat', 'zipimport', '_sysconfigdata', 'warnings', 'UserDict', 'encodings.utf_8', 'sys', 'peak.util', 'peak', 'repoze', 'readline', 'paste', 'os.path', 'signal', 'traceback', 'linecache', 'posix', 'encodings.aliases', 'oslo', 'exceptions', 'sre_parse', 'abrt_exception_handler', 'os', '_weakref'] -
AuthorPosts
Viewing 1 post (of 1 total)