Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #47460

Re: Listing modules from all installed packages

Newsgroups comp.lang.python
Date 2013-06-09 05:51 -0700
References <210f2f63-13b0-46c2-b080-fd831cb3ca49@googlegroups.com> <mailman.2908.1370758945.3114.python-list@python.org>
Message-ID <ce98a2f2-72e1-4a57-9964-f10c98100df0@googlegroups.com> (permalink)
Subject Re: Listing modules from all installed packages
From cclauss@bluewin.ch

Show all headers | View raw


Adding : python -c 'help("modules") to the other two suggestions:

#!/usr/bin/env python

import commands, pkgutil, re, sys

print('sys.modules.items()...')
print('\n'.join(sorted([re.findall("from '(.*)'",str(v))[0] for k,v in sys.modules.items() if str(v).find('from')>-1])))

print('\npkgutil.iter_modules()...')
toplevel_packages = ['%s\\%s'%(ml.path,name)for ml,name,ispkg in sorted(pkgutil.iter_modules()) if ispkg]
print '\n'.join(toplevel_packages)

theCommand = "python -c 'help(\"modules\")'"
print('\n{} # this may take a few seconds...'.format(theCommand))
print(commands.getstatusoutput(theCommand)[1]) # help() only works in the python interpreter...

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Listing modules from all installed packages Julien Phalip <jphalip@gmail.com> - 2013-06-08 21:30 -0700
  RE: Listing modules from all installed packages Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-06-09 08:23 +0300
    Re: Listing modules from all installed packages 88888 Dihedral <dihedral88888@gmail.com> - 2013-06-09 11:57 -0700
  RE: Listing modules from all installed packages Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-06-09 09:22 +0300
    Re: Listing modules from all installed packages cclauss@bluewin.ch - 2013-06-09 05:51 -0700
    Re: Listing modules from all installed packages Julien Phalip <jphalip@gmail.com> - 2013-06-14 12:18 -0700

csiph-web