[Tutor] Listing imported modules

Emile van Sebille emile at fenx.com
Sat Sep 13 19:38:42 CEST 2008


Tim Johnson wrote:
> If I execute the following code:
> 
> imported = sys.modules.keys()
> 
> print imported
> 
> Do I indeed get a list of _all_ modules imported by this module?
> 
> If so, then could anyone offer suggestion on how to "parse" the
> 
> non-standard modules from this list. I.E. modules _not_ included in
> 
> the standard python distribution.

Hmmm...  it looks to me that you can import site and use sitedirs to 
identify the paths used for third party packages.  Then filter __file__ 
of the sys.modules.keys() against that.

HTH,

Emile



More information about the Tutor mailing list