I’m trying to understand what is going on here, specifically how curids is getting set:
for idx in xrange(0, int(math.ceil(float(len(mids))/chunk))):
curids = mids[int(idx*chunk):int((idx*chunk)+chunk)]
I’m not sure what the syntax for mids[int(idx*chunk):int((idx*chunk)+chunk)] is trying to do.
It extracts blocks of
midsintocurids, where each block consists ofchunkelements.If you change the loop to print out the values of
int(idx*chunk)andint((idx*chunk)+chunk)], you’ll see that for yourself.For example, if
len(mids)==50andchunk==12, the indices that would get printed are:These are the starting and ending indices of each slice of
mids(the start index is inclusive and the end index is not).Note that the last value is allowed to go above
len(mids), but that’s not a problem given how Python slicing works (it’ll just slice to the end ofmids).