© Kristian Rother 2017

Kristian Rother, Pro Python Best Practices, 10.1007/978-1-4842-2241-6_2

2. Exceptions in Python

Kristian Rother

(1)Berlin, Germany

Once we accidentally inserted an extra zero in the headline: ‘2000 tanks destroyed.’ The authorities were quite angry.

—memories of my grandfather while working in a printing press in 1941

As soon as a program contains a single line of program code, that line could contain a defect—and sooner or later it will. If defects are when our code does not do what it is expected to do, debuggingis fixing those defects. This is more complicated than it sounds. Debugging implies a couple of things:

  • We know what a correct program is supposed to do.

  • We know that there is a defect in our program.

  • We acknowledge ...

Get Pro Python Best Practices: Debugging, Testing and Maintenance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.