Import a lot of modules, or, import 'foo'

Robert J. Roy rjroyNoSpam at magma.ca
Sat Jul 31 00:17:52 EDT 1999


On 30 Jul 1999 17:52:32 -0700, dwelton at linuxcare.com (David N. Welton)
wrote:

>
>So, basically, I'd like to do this:
>
> tests = ['fs', 'swap']
>
> for t in tests:
>     import t
>
> do more stuff on what promises to be a lot of modules
>
>I've looked around a bit, but can't find what I need.  Maybe I'm just
>going about this the wrong way, but... Hmm, now I want to know how to
>do this in any case:-)
>
>Thanks,
>-- 
>David N. Welton, Web Engineer, Linuxcare, Inc.
>415.354.4878 x241 tel, 415.701.7457 fax
>dwelton at linuxcare.com, http://www.linuxcare.com/
>Linuxcare. At the center of Linux.

you can use the builtin function __import__

See 
http://www.pythonware.com/people/fredrik/fyi/fyi06.htm
for more info




More information about the Python-list mailing list