4259 links
  • Arnaud's links
  • Home
  • RSS Feed
  • Tag cloud
  • Login
search: tag:python tag:exception — newest first
  • Stupid Python Tricks: The KeyboardInterrupt Exception

    catching all exception in python
    import traceback

    for record in database:
    try:
    blabla
    except (KeyboardInterrupt, SystemExit):
    raise
    except Exception as e:
    # report error and proceed
    print(type(e).name)
    print(e)
    print(traceback.format_exc())

    Ne pas oublier de raise si on veut re-raise

    April 21, 2017 - permalink - http://effbot.org/zone/stupid-exceptions-keyboardinterrupt.htm
    exception nomarkdown python