recursive import list martin.witte at
Mon Jun 13 22:17:33 CEST 2005

If you use your own import function, like below, you could create a
list of all imported modules.

#!/usr/bin/env python

mod_list = []

def my_import(name, globals = None, locals = None, fromlist = None):
    mod = __import__(name, globals, locals, fromlist)
    return mod

os = my_import('os')

print mod_list

sys = my_import('sys')
print sys.version

print mod_list

More information about the Python-list mailing list