I have a list of files, I want to iterate and import functions from those files, so as to work on them one by one, python
<p>I have a list of files, using command in python <code>from filename import *</code> , works for a single file as I am giving the exact name of the file, but if I want to use it as <code>from list[i] import *</code> to iterate over a list and importing function from files one after the another to  work on it, it doesn't work? what changes should I make so as to use it for a list of files, so that I can easily iterate?</p>

<p>If you're looking for dynamic imports, you're looking for the <code>__import__</code> function.</p>

<pre><code>for modl in ('foo', 'bar', 'baz', 'bat',):
    __import__('parent.' + modl)
</code></pre>

python file file-handling