O'Reilly logo

Head First Python, 2nd Edition by Paul Barry

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11. Exception Handling: What to Do When Things Go Wrong

image with no caption

Things go wrong, all the time—no matter how good your code is.

You’ve successfully executed all of the examples in this book, and you’re likely confident all of the code presented thus far works. But does this mean the code is robust? Probably not. Writing code based on the assumption that nothing bad ever happens is (at best) naive. At worst, it’s dangerous, as unforeseen things do (and will) happen. It’s much better if you’re wary while coding, as opposed to trusting. Care is needed to ensure your code does what you want it to, as well as reacts properly when things go south. In this chapter, you’ll not only see what can go wrong, but also learn what to do when (and, oftentimes, before) things do.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required