Entry
How do I find out what modules are available on my system?
Jun 19th, 2002 11:51
Michael Chermside,
Python comes with lots of modules, and there are hundreds of (excellent)
modules available for download. So how can you find out what is
available on your machine? I'll give three different approaches.
SOLUTION 1:
The following code will generate a list of all modules available on your
system:
Python 2.2.1 (#34, Apr 9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> modules = []
>>> def addModuleToList( path, moduleName, description ):
... modules.append( moduleName )
...
>>> import pydoc
>>> pydoc.ModuleScanner().run( addModuleToList )
>>> print modules
[... LOTS OF OUTPUT HERE ...]
SOLUTION 2:
If you prefer a graphical approach, start up Idle, the free
multi-platform editor that comes with Python, and select "Path Browser"
from the "File" menu. This will show, not only modules, but the
individual classes and functions defined within each module.
SOLUTION 3:
If you serving up CGI scripts on a web server, you may well have
extremely limited access to the system... some don't even allow telnet
access. But if you at least have permission to run CGI scripts, then
snakefarm.org's "SnakeCharmer" script is the tool for you. Find it at
"http://snakefarm.org/".
FINAL NOTE:
It's fun sometimes to just poke around through the standard modules in
Python to see what you find. It's often educational, and sometimes
amusing. If you are bored sometime, try executing "import this".