from spam import eggs, spam at runtime, how?

Ganesan R rganesan at
Tue Dec 9 05:46:18 CET 2003

>>>>> "Fredrik" == Fredrik Lundh <fredrik at> writes:

>     spam = __import__('spam.eggs')
>     eggs = spam.eggs

Is there a way to do this if I don't know about "eggs" beforehand. I have
some code which needs to import a DB module dynamically. The module could be
'PyPgSQL.PgSQL' or 'sqlite'. Is there a sane way to do this without exec?


Ganesan R

More information about the Python-list mailing list