<p>How do I limit <code>os.walk</code> to only return files in the directory I provide it?</p>

<pre><code>def _dir_list(self, dir_name, whitelist):
    outputList = []
    for root, dirs, files in os.walk(dir_name):
        for f in files:
            if os.path.splitext(f)[1] in whitelist:
                outputList.append(os.path.join(root, f))
            else:
                self._email_to_("ignore")
    return outputList
</code></pre>

You could use
```
os.listdir()
```
which returns a list of names (for both files and directories) in a given directory. If you need to distinguish between files and directories, call
```
os.stat()
```
on each name.