dynamically import

Gerhard Häring gerhard.haering at opus-gmbh.net
Fri Jan 31 02:54:12 EST 2003


Reid Lai <reidlai at reidlai.com> wrote:
> Dear All,
> 
> How can I have a database connection depending on different DBI 2.0 
> module dynamically? [...]

You're looking for the __import__ builtin function. I just noticed that
__import__ -ing submodules is a little tricky. You might want to look at the
documentation for __import__ and the my_import() example there. [1]

-- Gerhard

[1] http://www.python.org/doc/current/lib/built-in-funcs.html#l2h-2




More information about the Python-list mailing list