Debugging in Python, part 12: Using an IDE's debugger

MP 155: Using an IDE debugger to understand a program's internal behavior.

Note: This post is part of an ongoing series about debugging in Python. The posts in this series will only be available to paid subscribers for the first 6 weeks. After that they will be available to everyone. Thank you to everyone who supports my ongoing work on Mostly Python.

In the last post, we started implementing the game play for Go Fish. We were working on managing the player's turn, and things were working well in some play-throughs. However, there were some play sequences that demonstrated buggy behavior. In this post we'll use an IDE's interactive debugger to get to the root of that problematic behavior.

A repeatable bug, even when using random

At the end of the last post I showed a couple examples of incorrect behavior when managing the player's first turn. All the examples I've come up with involve the behavior after an invalid guess is handled correctly.

Debugging logic that involves randomness can be difficult, because it can be hard to consistently generate the same buggy conditions. One strategy for addressing this is to give the random number generator a seed, so you can generate repeatable output.

Starting with the most recent version of the Go Fish code, let's add a random seed to the game so we can work with deterministic output:

This post is only available to paid subscribers at the moment. It will be available to everyone 6 weeks after posting. If you'd like to continue reading now, please support my work by signing up for a paid subscription.

Paid subscription options