for f in os.listdir(os.path.abspath(libdir)):
module_name = f.strip('.py')
__import__(module_name, globals(), locals(), [])
On 7/14/05, Jesse Noller <[EMAIL PROTECTED]> wrote:
> A question in a similiar vein:
>
> I have appended 2 different directories to my path (via
> sys.path.append) now - without knowing the names of the files in those
> directories, I want to force an import of the libraries ala:
>
> for f in os.listdir(os.path.abspath(libdir)):
> module_name = f.strip('.py')
> import module_name
>
> Obviously, this throws:
>
> ImportError: No module named module_name
>
> Is there some way to do this?
>
> thanks
> -jesse
>
--
http://mail.python.org/mailman/listinfo/python-list