from spam import eggs, spam at runtime, how?

John J. Lee jjl at pobox.com
Tue Dec 9 12:02:13 EST 2003


Rene Pijlman <reply.in.the.newsgroup at my.address.is.invalid> writes:

> How do I do:
> 
>    from spam import eggs
> 
> ... when 'spam' is only known at runtime?

Why not just stick the import statement where you need it?

def do_something_that_needs_spam_module():
    import spam
    ...


John




More information about the Python-list mailing list