def print_exception(etype, value, tb, limit=None, file=None):
if file is None:<EOL><INDENT>file = open('<STR_LIT>', '<STR_LIT:w>')<EOL><DEDENT>if tb:<EOL><INDENT>_print(file, '<STR_LIT>')<EOL>print_tb(tb, limit, file)<EOL><DEDENT>lines = format_exception_only(etype, value)<EOL>for line in lines:<EOL><INDENT>_print(file, line, '<STR_LIT>')<EOL><DEDENT>
Print exception up to 'limit' stack trace entries from 'tb' to 'file'.

    This differs from print_tb() in the following ways: (1) if
    traceback is not None, it prints a header "Traceback (most recent
    call last):"; (2) it prints the exception type and value after the
    stack trace; (3) if type is SyntaxError and value has the
    appropriate format, it prints the line where the syntax error
    occurred with a caret on the next line indicating the approximate
    position of the error.