Module list generation

Scott David Daniels Scott.Daniels at Acm.Org
Fri Dec 3 12:20:34 EST 2004


Doug Kearns wrote:
> Is this the best/simplest way to generate a module list?
> 
> python -c 'from pydoc import help; help("modules")'
> 
> Thanks,
> Doug
I am not sure if this is what you want, but how about:

For python 2.4, try:
python -c "import sys; print sorted(sys.modules)"

For earlier pythons, use:
  python -c "import sys; nms = sys.modules.keys(); nms.sort(); print nms"
or:
  python -c "import sys; print sys.modules.keys()"
if you don't care about order.

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list