Listing modules from all installed packages

Julien Phalip jphalip at gmail.com
Fri Jun 14 15:18:34 EDT 2013


On Saturday, June 8, 2013 11:22:16 PM UTC-7, Carlos Nepomuceno wrote:
> Just realized that you've asked for installed packages. Perhaps the following will do the trick. I don't know why the 'lib-tk' isn't included. Why not?
> 
> toplevel_packages = ['%s\\%s'%(ml.path,name)for ml,name,ispkg in pkgutil.iter_modules() if ispkg]
> print '\n'.join(toplevel_packages)

Thanks a lot Carlos, this gives me exactly what I needed!

Best wishes,

Julien



More information about the Python-list mailing list