def extract_lines(code, line, padding=2):
    """Extracts a number of lines from code surrounding a given line number,
    returns a list of tuples that contain the line number (1 indexed) and the line text.

    """
    lines = code.splitlines()
    start = max(0, line - padding - 1)
    end = min(len(lines), line + padding - 1)
    showlines = lines[start : end + 1]
    linenos = [n + 1 for n in range(start, end + 1)]
    return zip(linenos, showlines)