code: def iterline(x1, y1, x2, y2):
      'Yields (x, y) coords of line from (x1, y1) to (x2, y2)'
      xdiff = abs(x2-x1)
      ydiff = abs(y2-y1)
      xdir = 1 if x1 <= x2 else -1
      ydir = 1 if y1 <= y2 else -1
  
      r = math.ceil(max(xdiff, ydiff))
      if r == 0:  # point, not line
          yield x1, y1
      else:
          x, y = math.floor(x1), math.floor(y1)
          i = 0
          while i < r:
              x += xdir * xdiff / r
              y += ydir * ydiff / r
  
              yield x, y
              i += f iterline(x1, y1, x2, y2):
      'Yields (x, y) coords of line from (x1, y1) to (x2, y2)'
      xdiff = abs(x2-x1)
      ydiff = abs(y2-y1)
      xdir = 1 if x1 <= x2 else -1
      ydir = 1 if y1 <= y2 else -1
  
      r = math.ceil(max(xdiff, ydiff))
      if r == 0:  # point, not line
          yield x1, y1
      else:
          x, y = math.floor(x1), math.floor(y1)
          i = 0
          while i < r:
              x += xdir * xdiff / r
              y += ydir * ydiff / r
  
              yield x, y
              i += 1
docs: Yields (x, y) coords of line from (x1, y1) to (x2, y2)