from spam import eggs, spam at runtime, how?

Ganesan R rganesan at myrealbox.com
Mon Dec 8 23:46:18 EST 2003


>>>>> "Fredrik" == Fredrik Lundh <fredrik at pythonware.com> 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

--
Ganesan R





More information about the Python-list mailing list