[Wolves] python module query

sparkes sparkes at westmids.biz
Mon Sep 6 11:00:46 BST 2004


sparkes wrote:

> I know I *should* be able to do this but for the life of me I can't 
> see how to do it.
>
> I want to load a module at runtime by passing it's name to a 
> function.  I just can't see how to load a module dynamically like 
> this.  I am pretty sure it can be done but I can't work it out.
>
> I thought sys.module might help but I can't work that out either ;-)
>
> I am pretty sure it's one of those things that will seem easy once I 
> know how to do it as well ;-)
>
> sparkes
>
exec 'import ' + <variable> + ' as my_mod'

thanks to Gareth Fleming GLLUG python study group ;-) posted here to 
save people time answering the question and to improve our mailing list 
archives

sparkes

-- 
                   _      __
    ______      __(_)____/ /_ 
   / ___/ | /| / / / ___/ __ \
  (__  )| |/ |/ / (__  ) / / /
 /____/ |__/|__/_/____/_/ /_/
t:07005 968 999 f:07005 968 888
      www.swishdesign.com 




More information about the Wolves mailing list