Handle iglob error when path to search doesn't exist
<p>I'm trying to use iglob instead of glob to get a list of say .txt files. If no .txt files exist, glob doesn't return any errors, but iglob does.</p>

<p>Code:</p>

<pre><code>def iGlobLatest():
    dir_list = glob.iglob('*.txt')
    print dir_list.next()
</code></pre>

<p>if no .txt files exist, I get this:</p>

<p>Traceback (most recent call last):</p>

<p>File "T:\prod\offlineValidation\scripts\goofin.py", line 98, in  iGlobLatest()</p>

<p>File "T:\prod\offlineValidation\scripts\goofin.py", line 88, in iGlobLatest print dir_list.next()</p>

<p>StopIteration</p>

<p>If I use try/except, I can avoid the error, but is that the only way? Other suggestions for checking the existence of .txt files involve using glob, but since I'm trying to use iglob instead of glob.... </p>
