""mydir pya module that lists the namespaces of other modules ""from __future__ import print_function compatibility seplen sepchr '-def listing(moduleverbose=true)sepline sepchr seplen if verboseprint(seplineprint('name:'module __name__'file:'module __file__print(seplinecount for attr in sorted(module __dict__)scan namespace keys (or enumerateprint('% % (countattr)end 'if attr startswith('__')print(''skip __file__etc elseprint(getattr(moduleattr)same as __dict__[attrcount + if verboseprint(seplineprint(module __name__'has % namescountprint(seplineif __name__ ='__main__'import mydir listing(mydirself-test codelist myself notice the docstring at the topas in the prior formats py examplebecause we may want to use this as general toolthe docstring provides functional information accessible via help and gui/browser mode of pydoc-- tool that uses similar introspection tools to do its job self-test is also provided at the bottom of this modulewhich narcissistically imports and lists itself here' the sort of output produced in python this script works on too (where it may list fewer namesbecause it prints from the __future__c:\codepy - mydir py namemydir filec:\code\mydir py __builtins__ __cached__ __doc__ __file__ __initializing__ __loader__ __name__ __package__ advanced module topics