⇤ ← Revision 1 as of 2005-04-14 22:54:05
1070
Comment: How dynamically find modules in a directory, import them, get a handle to them?
|
1213
|
Deletions are marked like this. | Additions are marked like this. |
Line 45: | Line 45: |
There seems to be [http://www.python.org/doc/current/lib/module-imp.html a module imp] that can be used to dynamically load a named module. |
I frequently want to find all the modules in some directory, with some property, and do something with them.
If you know how, please inform me. Here are some things I'm researching.
Finding the Things Inside a Module
1 module.__dict__
Identifying Functions
Finding Functions Within a Module
So, putting them together,...
Finding Modules in a Directory
Is there a better way than just listing the contents of the directory, and taking those tiles that end with ".pyc" or ".py"..?
Importing the Modules
How do you do it dynamically, just given a filename?
Once you've imported it, how do you get a handle on it? (That is, how do you get it's dict?)
There seems to be [http://www.python.org/doc/current/lib/module-imp.html a module imp] that can be used to dynamically load a named module.