how to import from variable source

Brian Quinlan brian at sweetapp.com
Sun Apr 15 18:02:22 EDT 2001


imp.find_module does not support hierarchical pacakges. From the docs:

"This function does not handle hierarchical module names (names containing
dots). In order to find P.M, i.e., submodule M of package P, use
find_module() and load_module() to find and load package P, and then use
find_module() with the path argument set to P.__path__. When P itself has a
dotted name, apply this recipe recursively."

-----Original Message-----
From: python-list-admin at python.org
[mailto:python-list-admin at python.org]On Behalf Of Martin Bless
Sent: Sunday, April 15, 2001 2:01 PM
To: python-list at python.org
Subject: Re: how to import from variable source


>> If - against normal behavior - it could be set to '__main__' the
>> imported 'mymod' could be deceived leading to execution of code
>
>You can do that with the imp.load_module() function.

Can it be done for hierarchical packages too?

I tried for quit a while now but can't figure it out.

Martin
--
http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list