Exception handling

Cards (4)

  • An exception is an exceptional or unexpected event that occurs when a program is running.
  • Exception handling refers to the way that a program handles exceptional circumstances. It is really important that, when an exception occurs, a program does not just 'crash'. This will always be a problem for the end user as it will prevent them from completing the task in hand.
  • Python uses try-except statements to handle exceptions.
  • Exception handling is also a requirement when writing code to deal with hardware problems. Processor interrupts are dealt with by interrupt routines, which are a form of exception handling.