Debugging Flashcards

1
Q

How to debug code

A

a large chunk of our time as Sr Developers is debugging our code.

Answering the question: Why doesn’t this work?

What do we expect the code to do?

What exactly is this code doing?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Recommended tools:

A

linting

IDEs or Editors: makes it easier for us to detect errors before we run the code

Learn to read errors:
*** There are about 15 - 20 common errors

If you see an error that you don’t recognize/understand, go to the Python documentation and learn about the error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

PDB

A

PDB is the Python Debugger and is a built-in module in Python

PDB is extremely useful bc it allows us to interact with the code

Although print is a great quick method for debugging, the set_trace method in the PDB module is the most useful. It opens up an interactive terminal the shows us the values of any variable

in the interactive prompt:

a: returns all the arguments
w: shows the context of the current line its executing

can write code and modify variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly