dynamic loading of modules

Henry Baumgartl h.baumgartl at quicknet.nl
Wed Mar 6 11:04:04 EST 2002


Hello all,

Having recently embarked on my journey into Python land, I would like to
know if there is an elegant solution to the following problem:

I would like to be able to compound variables that will then form the name
of the particular module to be loaded into the active script.

Long lists of -if- and -elif- statements don't really do the trick, as one
still has to hardcode all possible options and defeating the dynamic nature
of the application.

A solution I came up with was to write a new module every time the process
starts, and loading this to get to the dynamically selected sub-modules.
Unfortunately, as the name of the 'new' module needs to be hardcoded for
this scheme to work, only one user can safely use the application at any one
time, which is not good enough.

Any suggestions to resolve my dilemma will be greatly appreciated.

Best Regards,
Henry Baumgartl





More information about the Python-list mailing list