from spam import eggs, spam at runtime, how?

Aahz aahz at pythoncraft.com
Mon Dec 8 11:41:41 EST 2003


In article <br99tv8mgguso67p2a8h8p8sctr2o7olse at 4ax.com>,
Rene Pijlman  <reply.in.the.newsgroup at my.address.is.invalid> wrote:
>
>How do I do:
>   from spam import eggs
>... when 'spam' is only known at runtime?

spam = __import__('spam')
eggs = spam.eggs
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Weinberg's Second Law: If builders built buildings the way programmers wrote 
programs, then the first woodpecker that came along would destroy civilization.




More information about the Python-list mailing list