def walk_line(p0, p1):
    """Returns a generator of points in the line from p0 to p1 such
       that they are connected (in the way they would do to draw a
       line. Order of points is not guaranteed: points may go p0->p1
       or p1->p0. See walk_line_ordered if points must go from p0 to
       p1."""
    x0, y0 = p0
    x1, y1 = p1
    steep = abs(y1 - y0) > abs(x1 - x0)
    if steep:
        x0, y0 = y0, x0
        x1, y1 = y1, x1
    if x0 > x1:
        x0, x1 = x1, x0
        y0, y1 = y1, y0
    deltax = x1 - x0
    deltay = abs(y1 - y0)
    error = deltax / 2
    y = y0
    ystep = 1 if y0 < y1 else -1
    for x in range(x0, x1 + 1):
        yield (x, y) if not steep else (y, x)
        error = error - deltay
        if error < 0:
            y = y + ystep
            error = error + deltax
