1) removal of elements during iteration in the list from the end to the beginning of the list of dissolving problems
LOG_FILES = [ 1,2,30,2,5,8,30,3,2,37,22,30,27,30,4 ]
print LOG_FILES
L = len(LOG_FILES)-1
for i,x in enumerate(LOG_FILES[::-1]):
print i,L-i,' ',LOG_FILES[L-i],x
if x>15:
del LOG_FILES[L-i]
print LOG_FILES
result
[1, 2, 30, 2, 5, 8, 30, 3, 2, 37, 22, 30, 27, 30, 4]
0 14 4 4
1 13 30 30
2 12 27 27
3 11 30 30
4 10 22 22
5 9 37 37
6 8 2 2
7 7 3 3
8 6 30 30
9 5 8 8
10 4 5 5
11 3 2 2
12 2 30 30
13 1 2 2
14 0 1 1
[1, 2, 2, 5, 8, 3, 2, 4]
2) By the way,
if LOG_FILES[i].DATE < to_date and LOG_FILES[i].DATE > from_date :
can write
if from_date < LOG_FILES[i].DATE < to_date: