user modules

Cameron Walsh cameron.walsh at
Thu Oct 5 08:47:30 CEST 2006


I'm writing a python program to analyse and export volumetric data.  To 
make development and extension easier, and to make it more useful to the 
public when it is released (LGPL), I would like to enable users to place 
their own python files in a "user_extensions" directory.  These files 
would implement a common interface in order for the main program to be 
able to read them and execute the necessary code.

My question is what is the best way of implementing this?

I have investigated importing them as modules, but unless the user 
modifies the main program I cannot see how the main program can learn of 
the existence of specific modules.

For example:

from user_modules import *
# directory 'user_modules' contains allowing this
# From here I would need a list of the imported modules, in order to
# execute a common command on each of them, such as

for module in imported_modules:

How do I get from the first bit to the second bit, or is there a better 
way of obtaining the functionality I need?


More information about the Python-list mailing list