[Tutor] List of available modules
op73418 at mail.telepac.pt
Sat Apr 10 07:46:16 EDT 2004
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
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,
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.
More information about the Tutor