(self)
return result
Format the stack ready for printing.

        Returns a list of strings ready for printing.  Each string in the
        resulting list corresponds to a single frame from the stack.
        Each string ends in a newline; the strings may contain internal
        newlines as well, for those items with source text lines.

        For long sequences of the same frame and line, the first few
        repetitions are shown, followed by a summary line stating the exact
        number of further repetitions.
Format the stack ready for printing.
Format the stack ready for printing .
def format(self):
        """Format the stack ready for printing.

        Returns a list of strings ready for printing.  Each string in the
        resulting list corresponds to a single frame from the stack.
        Each string ends in a newline; the strings may contain internal
        newlines as well, for those items with source text lines.

        For long sequences of the same frame and line, the first few
        repetitions are shown, followed by a summary line stating the exact
        number of further repetitions.
        """
        result = []
        last_file = None
        last_line = None
        last_name = None
        count = 0
        for frame in self:
            if (last_file is None or last_file != frame.filename or
                last_line is None or last_line != frame.lineno or
                last_name is None or last_name != frame.name):
                if count > _RECURSIVE_CUTOFF:
                    count -= _RECURSIVE_CUTOFF
                    result.append(
                        f'  [Previous line repeated {count} more '
                        f'time{"s" if count > 1 else ""}]\n'
                    )
                last_file = frame.filename
                last_line = frame.lineno
                last_name = frame.name
                count = 0
            count += 1
            if count > _RECURSIVE_CUTOFF:
                continue
            row = []
            row.append('  File "{}", line {}, in {}\n'.format(
                frame.filename, frame.lineno, frame.name))
            if frame.line:
                row.append('    {}\n'.format(frame.line.strip()))
            if frame.locals:
                for name, value in sorted(frame.locals.items()):
                    row.append('    {name} = {value}\n'.format(name=name, value=value))
            result.append(''.join(row))
        if count > _RECURSIVE_CUTOFF:
            count -= _RECURSIVE_CUTOFF
            result.append(
                f'  [Previous line repeated {count} more '
                f'time{"s" if count > 1 else ""}]\n'
            )
        return result
def format ( self ) : result = [ ] last_file = None last_line = None last_name = None count = 0 for frame in self : if ( last_file is None or last_file != frame . filename or last_line is None or last_line != frame . lineno or last_name is None or last_name != frame . name ) : if count > _RECURSIVE_CUTOFF : count -= _RECURSIVE_CUTOFF result . append ( f'  [Previous line repeated {count} more ' f'time{"s" if count > 1 else ""}]\n' ) last_file = frame . filename last_line = frame . lineno last_name = frame . name count = 0 count += 1 if count > _RECURSIVE_CUTOFF : continue row = [ ] row . append ( '  File "{}", line {}, in {}\n' . format ( frame . filename , frame . lineno , frame . name ) ) if frame . line : row . append ( '    {}\n' . format ( frame . line . strip ( ) ) ) if frame . locals : for name , value in sorted ( frame . locals . items ( ) ) : row . append ( '    {name} = {value}\n' . format ( name = name , value = value ) ) result . append ( '' . join ( row ) ) if count > _RECURSIVE_CUTOFF : count -= _RECURSIVE_CUTOFF result . append ( f'  [Previous line repeated {count} more ' f'time{"s" if count > 1 else ""}]\n' ) return result