I can see no reason why you wouldn't use xrange()
(or range()
)
for xx in range(0, width, block_size):
for yy in range(0, height, block_size):
...
[EDIT]
rewriting the whole example, you will get something like:
for xx in range(0, width, block_size):
for yy in range(0, height, block_size):
print ("---", xx, yy)
offsetX = min(width, xx + block_size_half)
offsetY = min(height, yy + block_size_half)
r, g, b = matrix[xx + offsetX][yy + offsetY]
for x in range(xx, min(xx + block_size, width)):
for y in range(yy, min(yy + block_size, height)):
print (x, y)
matrix[x][y] = (r, g, b)
which can probably get even shorter.