getting list of all available modules

Peter Otten __peter__ at web.de
Tue Jun 21 07:51:50 EDT 2005


Benjamin Rutt wrote:

> I want to do the same (get all such modules in a python list); how can
> I do so?  Or where is the code for the REPL for help() itself so I can
> find out myself?

Get hold of the Python source code and grep for some (hopefully) selective
piece of text. In the case of help() you are lucky as it is implemented in
Python, and therefore searching the stdlib will do:

$ find /usr/local/lib/python2.4 -name \*.py |xargs grep "Please wait"
/usr/local/lib/python2.4/pydoc.py:Please wait a moment while I gather a list
of all available modules...

Looking into that file, a suspiciously named ModuleScanner class is right
over there. Now what is your excuse for not finding it yourself in the
first place? You seem to be on Linux, so "That's not how I do it with
Visual Basic" can't be it :-)

Peter




More information about the Python-list mailing list