"dynamical" importing

Laurent Rahuel lrahuel.notgood at voila.fr
Wed Oct 19 04:40:41 EDT 2005


Hi,

I guess you need to look at __import__

Regards,

Laurent.

Joerg Schuster wrote:

> Hello,
> 
> I need to import modules from user defined paths. I.e. I want to do
> something
> like:
> 
> module_dir = sys.argv[1]
> 
> my_path = os.path.join(module_dir, 'bin', 'my_module')
> 
> from my_path import my_object
> 
> Obviously, it doesn't work this way. How would it work?
> 
> Jörg Schuster




More information about the Python-list mailing list