Consider if I had a function that took a tuple argument (x,y), where x was in the range(X), and y in the range(Y), the normal way of doing it would be:
for x in
Try product from itertools: http://docs.python.org/library/itertools.html#itertools.product
from itertools import product for x, y in product(range(X), range(Y)): function(x, y)