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

Emile van Sebille emile at fenx.com
Fri Jul 30 21:03:57 EDT 1999


Hi David,

This seems to work for me:

>>> for t in tests:
 exec ('import %s' % t)


--

Emile van Sebille
emile at fenx.com
-------------------


David N. Welton <dwelton at linuxcare.com> wrote in message
news:874silabe7.fsf at linuxcare.com...
>
> 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.






More information about the Python-list mailing list