how to import a module from a arbitraty path?

Simon Brunning simon.brunning at gmail.com
Thu May 26 05:20:13 EDT 2005


On 5/26/05, Andy Leszczynski
<leszczynscyATnospam.yahoo.com.nospam at bag.python.org> wrote:
> I have a program which is going to dynamicly load components from some
> arbitrary defined paths. How to do that?

You can locate them with os.walk and fnmatch. Then you can temporarily
add the directory to sys,path, and import using __import__().

-- 
Cheers,
Simon B,
simon at brunningonline.net,
http://www.brunningonline.net/simon/blog/



More information about the Python-list mailing list