(self, arg)
l(ist) [first [,last] | .]

        List source code for the current file.  Without arguments,
        list 11 lines around the current line or continue the previous
        listing.  With . as argument, list 11 lines around the current
        line.  With one argument, list 11 lines starting at that line.
        With two arguments, list the given range; if the second
        argument is less than the first, it is a count.

        The current line in the current frame is indicated by "->".
        If an exception is being debugged, the line where the
        exception was originally raised or propagated is indicated by
        ">>", if it differs from the current line.
l(ist) [first [,last] | .]
l ( ist ) [ first [ last ] | . ]
def do_list(self, arg):
        """l(ist) [first [,last] | .]

        List source code for the current file.  Without arguments,
        list 11 lines around the current line or continue the previous
        listing.  With . as argument, list 11 lines around the current
        line.  With one argument, list 11 lines starting at that line.
        With two arguments, list the given range; if the second
        argument is less than the first, it is a count.

        The current line in the current frame is indicated by "->".
        If an exception is being debugged, the line where the
        exception was originally raised or propagated is indicated by
        ">>", if it differs from the current line.
        """
        self.lastcmd = 'list'
        last = None
        if arg and arg != '.':
            try:
                if ',' in arg:
                    first, last = arg.split(',')
                    first = int(first.strip())
                    last = int(last.strip())
                    if last < first:
                        # assume it's a count
                        last = first + last
                else:
                    first = int(arg.strip())
                    first = max(1, first - 5)
            except ValueError:
                self.error('Error in argument: %r' % arg)
                return
        elif self.lineno is None or arg == '.':
            first = max(1, self.curframe.f_lineno - 5)
        else:
            first = self.lineno + 1
        if last is None:
            last = first + 10
        filename = self.curframe.f_code.co_filename
        breaklist = self.get_file_breaks(filename)
        try:
            lines = linecache.getlines(filename, self.curframe.f_globals)
            self._print_lines(lines[first-1:last], first, breaklist,
                              self.curframe)
            self.lineno = min(last, len(lines))
            if len(lines) < last:
                self.message('[EOF]')
        except KeyboardInterrupt:
            pass
def do_list ( self , arg ) : self . lastcmd = 'list' last = None if arg and arg != '.' : try : if ',' in arg : first , last = arg . split ( ',' ) first = int ( first . strip ( ) ) last = int ( last . strip ( ) ) if last < first : # assume it's a count last = first + last else : first = int ( arg . strip ( ) ) first = max ( 1 , first - 5 ) except ValueError : self . error ( 'Error in argument: %r' % arg ) return elif self . lineno is None or arg == '.' : first = max ( 1 , self . curframe . f_lineno - 5 ) else : first = self . lineno + 1 if last is None : last = first + 10 filename = self . curframe . f_code . co_filename breaklist = self . get_file_breaks ( filename ) try : lines = linecache . getlines ( filename , self . curframe . f_globals ) self . _print_lines ( lines [ first - 1 : last ] , first , breaklist , self . curframe ) self . lineno = min ( last , len ( lines ) ) if len ( lines ) < last : self . message ( '[EOF]' ) except KeyboardInterrupt : pass