How to use nameFilters with QDirIterator?
<p>In PySide, when I use <code>QDirIterator</code>, how I can filter on files by name?</p>

<p>In the documentation, it talks about the parameter <code>nameFilters</code>:</p>

<ul>
<li><a href="https://srinikom.github.io/pyside-docs/PySide/QtCore/QDirIterator.html" rel="nofollow">https://srinikom.github.io/pyside-docs/PySide/QtCore/QDirIterator.html</a></li>
</ul>

<p>But when I try it, it doesn't filter the files by extension:</p>

<pre><code>from PySide import QtCore

it = QtCore.QDirIterator('.', nameFilters=['*.py'])
while it.hasNext():
    print it.next()

&gt;&gt; ./.
&gt;&gt; ./..
&gt;&gt; my_script.py
&gt;&gt; another_file.txt
</code></pre>

<p>With this code, I expected to get only the files with the extension <code>.py</code>.</p>

<p>The <code>nameFilters</code> parameter is not a keyword argument.</p>

<p>Unfortunately, PySide never raises an error if you pass keyword arguments that don't exist, which is a very poor design. APIs should never fail silently when given invalid inputs.</p>

<p>Anyway, your code will work correctly if you use a positional argument:</p>

<pre><code>it = QtCore.QDirIterator('.', ['*.py'])
</code></pre>

python iterator pyside qdir