Python IndexError when trying to go through a large list
<p>I have a list of approximately 200 000+ objects, each one representing a file (but not actually holding the file's contents, just the full path name and date).</p>

<p>The program I am writing copies any subset of these files, depending on the user-provided date range. I first create a list of all of the files in the source directory (with the <code>glob</code> module), create an instance of my file-representation class and add that instance to a list, like so:</p>

<pre><code>for f in glob.glob(srcdir + "/*.txt"):
    LOG_FILES.append(LogFile(f))
</code></pre>

<p>Now, to keep the copying of files quick and the block of code clean, I remove the LogFile objects that do not fit inside of the date range.</p>

<pre><code>for i in xrange(0, len(LOG_FILES)):
    if LOG_FILES[i].DATE &lt; from_date or LOG_FILES[i].DATE &gt; to_date:
        del(LOG_FILES[i])
</code></pre>

<p>Afterwards, I can just copy the files that are left in the list:</p>

<pre><code>for logfile in LOG_FILES:
    os.copy(logfile.PATH, destdir)
</code></pre>

<p>The issue occurs with the <code>for i in xrange...</code> example: I get thrown an IndexError when the value of <code>i</code> gets to 63792.</p>

<pre><code>IndexError: list index out of range.
</code></pre>

<p>Any ideas?</p>

<p><strong>EDIT</strong> Thank you very much for the quick responses! Now that I think about it, it was a silly oversight on my part. Again, thank you, everyone. :)</p>
