I just hit something interesting in Djano and thought I'd share. I was playing with some data from a queryset. I was somewhat aware its not your ordinary python list. However, I was surprised to see this issue:
I had a query that was returning TestResult objects. When I iterated over the list like:
for r in results: print r.measurement
I got the objects I expected. However, at the time I was coding I needed to know the loop index, so I did something like:
for i in xrange(results.count()) print results[i].measurement
This example acts like it works, but upon looking at the data I realized I got incorrect results. It seems like results[0] and results[1] are always the same, but I haven't dug enough to prove that's always the case.
Anyway, I had a feeling using the xrange approach was wrong to begin with, but it turns out to be actually wrong without telling you.
-andy