def print_exception(etype, value, tb, limit=None, file=None):
 if (file is None):
  file = sys.stderr
 if tb:
  _print(file, 'Traceback (most recent call last):')
  print_tb(tb, limit, file)
 lines = format_exception_only(etype, value)
 for line in lines[:(-1)]:
  _print(file, line, ' ')
 _print(file, lines[(-1)], '')

def print_exception ( etype , value , tb , limit = None , file = None ) : if ( file is None ) : file = sys . stderr if tb : _print ( file , 'Traceback (most recent call last):' ) print_tb ( tb , limit , file ) lines = format_exception_only ( etype , value ) for line in lines [ : ( - 1 ) ] : _print ( file , line , ' ' ) _print ( file , lines [ ( - 1 ) ] , '' )
print exception up to limit stack trace entries from tb to file .