'Print lines of code from the current stack frame'

def do_list(self, arg):

    self.lastcmd = 'list'
    last = None
    if arg:
        try:
            x = eval(arg, {}, {})
            if (type(x) == type(())):
                (first, last) = x
                first = int(first)
                last = int(last)
                if (last < first):
                    last = (first + last)
            else:
                first = max(1, (int(x) - 5))
        except:
            print ('***    Error    in    argument:', repr(arg))
            return
    elif (self.lineno is None):
        first = max(1, (self.curframe.f_lineno - 5))
    else:
        first = (self.lineno + 1)
    if (last is None):
        last = (first + 10)
    self.print_list_lines(self.curframe.f_code.co_filename, first, last)
    lineno = first
    filename = self.curframe.f_code.co_filename
    self.shell.hooks.synchronize_with_editor(filename, lineno, 0)
