2

Is there, hopefully, an easy way to list Python standard library modules and class submodules?

I read this question but it's not working for me, not because it lists all available modules (can be tweaked to avoid, I know) but it does not include submodules. Like for example it lists module urllib but without submodule classes:

urllib.ContentTooShortError      urllib.main                      urllib.splituser
urllib.FancyURLopener            urllib.noheaders                 urllib.splitvalue
urllib.MAXFTPCACHE               urllib.os                        urllib.ssl
urllib.URLopener                 urllib.pathname2url              urllib.string
urllib.addbase                   urllib.proxy_bypass              urllib.sys
urllib.addclosehook              urllib.proxy_bypass_environment  urllib.test
urllib.addinfo                   urllib.quote                     urllib.test1
urllib.addinfourl                urllib.quote_plus                urllib.thishost
urllib.always_safe               urllib.reporthook                urllib.time
urllib.basejoin                  urllib.socket                    urllib.toBytes
urllib.c                         urllib.splitattr                 urllib.unquote
urllib.ftpcache                  urllib.splithost                 urllib.unquote_plus
urllib.ftperrors                 urllib.splitnport                urllib.unwrap
urllib.ftpwrapper                urllib.splitpasswd               urllib.url2pathname
urllib.getproxies                urllib.splitport                 urllib.urlcleanup
urllib.getproxies_environment    urllib.splitquery                urllib.urlencode
urllib.i                         urllib.splittag                  urllib.urlopen
urllib.localhost                 urllib.splittype                 urllib.urlretrieve

So is there some other way?

Community
  • 1
  • 1
theta
  • 24,593
  • 37
  • 119
  • 159
  • 1
    http://stackoverflow.com/questions/1707709/list-all-the-modules-that-are-part-of-a-python-package – dierre Oct 23 '11 at 14:03
  • so, you are suggesting I use my linked question for listing SPL modules then use `pkgutil` for printing submodules? If that's so is there some other way without importing whole Python library? Thanks – theta Oct 23 '11 at 14:13
  • To make helper file for tooltips :) – theta Oct 23 '11 at 14:23
  • @zetah: well, it's not your question, the one I linked is more complete. It's not the only solution but it's a good solution because in this way you have not to find actually all packages that can be stored in many formats. – dierre Oct 23 '11 at 14:54
  • It's good solution indeed, thanks. It seems I'll have to import modules to file submodules, with any kind of approach. I made list of SPL modules (from docs.python.org) and almost ready to process it. Cheers – theta Oct 23 '11 at 14:57

1 Answers1

1

To drill into submodules use the inspect and pyclbr modules. Those are the same support tools used by pydoc, help, and sphinx.

Good luck with your tooltip maker.

Raymond Hettinger
  • 216,523
  • 63
  • 388
  • 485