def floodFill4(m, r, c, newCol, oldCol): stack = [ (r, c) ] while stack: r, c = stack.pop() if c >=0 and c < maxc and r >=0 and r< maxr and m[r][c]==oldCol: m[r][c] = newCol stack += [ (r+1, c), (r-1, c), (r, c+1), (r, c-1) ]
-- http://mail.python.org/mailman/listinfo/python-list