from spam import eggs, spam at runtime, how?

Paul Rubin http
Mon Dec 8 14:56:10 EST 2003


Rene Pijlman <reply.in.the.newsgroup at my.address.is.invalid> writes:
> >    spam = __import__('spam.eggs')
> >    eggs = spam.eggs
> 
> Yes, and a bit more elegant (pythonic?). Thanks.

Another way:   

  exec 'import spam'




More information about the Python-list mailing list