[Tutor] List of available modules

John M. Purser jmpurser at comcast.net
Sat Apr 10 10:01:41 EDT 2004

Just so I can measure the duration of my ignorance:
How long has Python had help()?


John Purser

-----Original Message-----
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org]On
Behalf Of Goncalo Rodrigues
Sent: Saturday, April 10, 2004 5:46 AM
To: tutor at python.org
Subject: Re: [Tutor] List of available modules

Em Fri, 9 Apr 2004 17:06:39 -0700 (PDT), Danny Yoo
<dyoo at hkn.eecs.berkeley.edu> atirou este peixe aos pinguins:

>On Fri, 9 Apr 2004, [ISO-8859-1] Gon?o Rodrigues wrote:
>> Em Fri, 9 Apr 2004 14:03:47 -0700 (PDT), Marilyn Davis
>> <marilyn at deliberate.com> atirou este peixe aos pinguins:
>> >
>> >I think I remember that I can import something so that I can look at
>> >the list of available modules.  Can anyone remind me of how that goes?
>> >
>> What do you mean by "list of available modules", the modules that are
>> available for import? As far as I know there isn't one. There can be
>> many such, not just the ones from the standard library but also
>> third-party ones. The docs are your best bet.
>Actually, there is a way to do it: 'help()' knows what modules are
>>>> help('modules')

Thanks for correcting me!

Do you know if help("modules") also lists third-party modules? And how
about reliability? I mean, *how* does it gather the list of modules?
Since there isn't a central registry of installed Python modules I
suppose that it just crawls through the "standard paths" (the standard
lib + site-packages + ...) and gathers all files with .py extension.
Of course this can pick up files which are not, strictly speaking,
modules, like scripts which are not meant to be imported.

Anyway, thanks for the info, with my best regards,
G. Rodrigues

P.S: After writing the above, I fired up Python and tried
help("modules"). It indeed crawls through sys.path and picks the
modules/packages. I know this, because my sitecustomize.py file is
customized to append some directories to sys.path with some of my own
modules (to facilitate testing). So the first question, and I would
assume the second also, are answered.

Tutor maillist  -  Tutor at python.org

More information about the Tutor mailing list