(etype, value, tb, limit=None, chain=True)
return list
Format a stack trace and the exception information.

    The arguments have the same meaning as the corresponding arguments
    to print_exception().  The return value is a list of strings, each
    ending in a newline and some containing internal newlines.  When
    these lines are concatenated and printed, exactly the same text is
    printed as does print_exception().
Format a stack trace and the exception information.
Format a stack trace and the exception information .
def format_exception(etype, value, tb, limit=None, chain=True):
    """Format a stack trace and the exception information.

    The arguments have the same meaning as the corresponding arguments
    to print_exception().  The return value is a list of strings, each
    ending in a newline and some containing internal newlines.  When
    these lines are concatenated and printed, exactly the same text is
    printed as does print_exception().
    """
    list = []
    if chain:
        values = _iter_chain(value, tb)
    else:
        values = [(value, tb)]
    for value, tb in values:
        if isinstance(value, str):
            list.append(value + '\n')
            continue
        if tb:
            list.append('Traceback (most recent call last):\n')
            list.extend(format_tb(tb, limit))
        list.extend(format_exception_only(type(value), value))
    return list
def format_exception ( etype , value , tb , limit = None , chain = True ) : list = [ ] if chain : values = _iter_chain ( value , tb ) else : values = [ ( value , tb ) ] for value , tb in values : if isinstance ( value , str ) : list . append ( value + '\n' ) continue if tb : list . append ( 'Traceback (most recent call last):\n' ) list . extend ( format_tb ( tb , limit ) ) list . extend ( format_exception_only ( type ( value ) , value ) ) return list